Modify onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) method in MainActivity.java from last exercise "Example to use YouTubePlayerFragment of YouTube Android Player API".
public static final String PlayList_ID = "PLP7qPet500dfglA7FFTxBmB_snxCaMHDJ";
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean wasRestored) {
youTubePlayer = player;
Toast.makeText(getApplicationContext(),
"YouTubePlayer.onInitializationSuccess()",
Toast.LENGTH_LONG).show();
youTubePlayer.setPlayerStateChangeListener(myPlayerStateChangeListener);
youTubePlayer.setPlaybackEventListener(myPlaybackEventListener);
if (!wasRestored) {
//player.cueVideo(VIDEO_ID);
player.cuePlaylist(PlayList_ID);
}
}
Download the files.
Download APK to try on your device.
The tutorial: YouTube Android Player API step-by-step
how can I display all the videos in a PLAYLIST_ID LISTVIEW?
ReplyDeleteHi Thank you so much for sharing this useful stuff, I am working on it to get full benefit of playing Youtube Playlist, I just want to refresh Youtube player view with the one (youtube video) I have tapped in a List, but whenever I do tap on any of the list item not able to reload youtube video with tapped one.
ReplyDeleteSo How can I change Youtube Video in a Youtube Player, I have written complete code, please visit: http://stackoverflow.com/questions/34017783/how-to-refresh-youtube-player-view-onitemclicklistener-in-a-listview