Skip to main content

Playlist initialization

Overview


Playlist initialization and functions

As of VP Player SDK for Android 2.5.+ Playlist content overlay is supported.

To initialize playlist you should add PlaylistModel to VideoModel.

Code example
var playlistModel = PlaylistModel(true, "Id of Playlist", "Title of Playlist",Array of Video Entity Models)
var videoModel = VideoModel()
videoModel.playlist = playlistModel
videoPlayer?.setup(.....)

A player state event is fired whenever a video is finished, a video on a playlist is tapped, the next button or the back button is tapped.

Code example
videoPlayer?.setPlayerStateDelegate(object : PlayerStateDelegate {
override fun onPlayerStateChanged(playerEvent: PlayerEvent<Any>) {
if (playerEvent.type == PlayerState.RELATED_PLAYED) {
videoPlayer?.changeVideo("Video that should be played next")
}
}
}
})

playerEvent.value will return the EntityModel of Video that should play.

tip

If you don't want to initialize the playlist automatically set autoInitializeRelatedVideos on configs to false.

Playlist Aditional functions

openRelatedOverlay() - Used to Show Playlist Overlay

closeRelatedOverlay() - Used to Hide Playlist Overlay