我正在使用youtube api播放Youtube播放列表。但是在播放播放列表的最后一个视频时,播放器不会播放第一个视频。
我已经google了很多,并检查了所有youtube api但找不到任何解决方案。
我正在使用 YouTubePlayerSupportFragment 播放视频播放列表。如何设置循环变量以启用循环功能。
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
mplayer = player;
final class MyPlaylistEventListener implements PlaylistEventListener{
@Override
public void onNext() {
// TODO Auto-generated method stub
}
@Override
public void onPlaylistEnded() {
}
@Override
public void onPrevious() {
// TODO Auto-generated method stub
}
}
MyPlayerStateChangeListener myPlayerStateChangeListener = new MyPlayerStateChangeListener();
MyPlaylistEventListener myPlaylistEventListener = new MyPlaylistEventListener();
player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
player.setPlayerStateChangeListener(myPlayerStateChangeListener);
player.setPlaylistEventListener(myPlaylistEventListener);
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
if (!wasRestored) {
player.loadPlaylist("playlistID", videoIndex, 0);
}
}`
提前致谢。
答案 0 :(得分:2)
您是否尝试在您创建的侦听器中编辑onPlaylistEnded()状态?
@Override
public void onPlaylistEnded() {
player.loadPlaylist("playlistID", videoIndex, 0);
}