Created
June 10, 2019 09:03
-
-
Save tizisdeepan/0b3a32f3a333c0268be0d1dc0e24adc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mainHandler = Handler() | |
val url = "YOUR_VIDEO_URL" | |
val bandwidthMeter = DefaultBandwidthMeter() | |
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter) | |
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory) | |
val player = ExoPlayerFactory.newSimpleInstance(this, trackSelector) | |
videoView.player = player | |
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial"), bandwidthMeter) | |
val videoSource = if (url.contains(".m3u8")) HlsMediaSource(Uri.parse(url), dataSourceFactory, mainHandler, null) | |
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url)) | |
player.prepare(videoSource) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment