Created
September 27, 2020 21:12
-
-
Save prateek54/7ae0e865b30b1f241761dd3f46774f17 to your computer and use it in GitHub Desktop.
ExoPlayerDemo
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
private fun initPlayer() { | |
player = SimpleExoPlayer.Builder(this).build() | |
player?.playWhenReady = true | |
player_exo.player = player | |
val defaultHttpDataSourceFactory = DefaultHttpDataSourceFactory("ExoPlayerDemoUserAgent") | |
val mediaItem = MediaItem.fromUri("uri") | |
val mediaSource = | |
HlsMediaSource.Factory(defaultHttpDataSourceFactory).createMediaSource(mediaItem) | |
player?.setMediaSource(mediaSource) | |
player?.seekTo(playbackPosition) | |
player?.playWhenReady = playWhenReady | |
} | |
private fun releasePlayer() { | |
player?.let { | |
playbackPosition = it.currentPosition | |
playWhenReady = it.playWhenReady | |
it.release() | |
player = null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment