-
Notifications
You must be signed in to change notification settings - Fork 2
Playlist API
Devrath edited this page Oct 31, 2021
·
3 revisions
- Using
ConcatenatingMediaSource
, it is possible to play the sequence ofMediaItem
where we can prepare eachmedia item
and chain one after another. - Earlier this support was not available but now the player has a built-in feature available for this in the latest version of exo-player.
- We prepare the media source and send it to the exo-player, and the exo-player internally takes care of making the
media source
for each item in the list, and we explicitly do not need to worry about it. -
MediaItem
is added to the playlist, the player converts it internally into a playableMediaSource
. By default, the library does this using aDefaultMediaSourceFactory
.
SimpleExoPlayer.Builder(context)
.setTrackSelector(trackSelector)
.build()
.also { exoPlayer ->
callback.invoke(PlaylistExoplayerAction.BindCustomExoplayer(exoPlayer))
val videosList = dashItemList()
val type: String = MimeTypes.APPLICATION_MPD // -> DASH
val mediaItems: MutableList<MediaItem> = ArrayList()
for (i in 0 until videosList.size) {
val mediaItem = MediaItem.Builder()
.setUri(videosList[i].uri)
.setMimeType(type)
.build()
mediaItems.add(mediaItem)
}
exoPlayer.setMediaItems(mediaItems)
exoPlayer.playWhenReady = playWhenReady
exoPlayer.seekTo(currentWindow, playbackPosition)
exoPlayer.prepare()
}