Skip to content

Instantly share code, notes, and snippets.

@tizisdeepan
Created June 10, 2019 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tizisdeepan/803e3d43818b4994d586b606c013bba7 to your computer and use it in GitHub Desktop.
Save tizisdeepan/803e3d43818b4994d586b606c013bba7 to your computer and use it in GitHub Desktop.
val url = "YOUR_VIDEO_URL"
val player = ExoPlayerFactory.newSimpleInstance(this)
videoView.player = player
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial"))
val mediaSource = if (url.contains(".m3u8")) DashMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
player.prepare(mediaSource)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment