I've managed to implement PierfrancescoSoffritti library and obtained almost all functionality from the deprecated youtube android API, except I'm unable to load a playlist. I've read that the library was extended to implement this option but is not available in the code. Can someone show an example of how to load playlist in PierfrancescoSoffritti library?
This is the code I use, it is still a work in the progress. the problem is loadPlaylist...is not available...
var youTubePlayerView: YouTubePlayerView = findViewById(R.id.youtube_player_view) ProcessLifecycleOwner.get().lifecycle.addObserver(youTubePlayerView)
youTubePlayerView.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
override fun onReady(youTubePlayer: YouTubePlayer) {
val videoId = "MZPTKmm4Dy4"
/////////////////////////////////////////////////////////////
//cannot load playlist by calling a function here
//youTubePlayer.loadPlaylist(videoId, 0f)
/////////////////////////////////////////////////////////////
youTubePlayer.loadVideo(videoId, 0f)
youTubePlayer.play()
}
override fun onStateChange(
youTubePlayer: YouTubePlayer,
state: PlayerConstants.PlayerState
) {
// super.onStateChange(youTubePlayer, state)
if(state == PlayerConstants.PlayerState.PLAYING)
{
//to implement code
}
if(state == PlayerConstants.PlayerState.ENDED)
{
//to implement code
}
if(state == PlayerConstants.PlayerState.PAUSED)
{
//to implement code
}
if(state == PlayerConstants.PlayerState.UNKNOWN)
{
//to implement code
}
if(state == PlayerConstants.PlayerState.BUFFERING)
{
//to implement code
}
}
}
If you go to github repository there is an activity called "PlaylistExampleActivity".
Basically, you need to follow the code below.
I hope you understand this code.