在Youtube
播放列表中,我有很多Videos
,现在我想与其他人分享Videos
(使用视频网址 - 现在正在播放)
我使用以下代码在YouTube
应用中播放Android
播放列表:
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.cuePlaylist(PlayList_ID);
}
}
答案 0 :(得分:1)
在onLoaded()中你可以从你可以创建url的id获取id。
你可以这样。
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored) {
player.setPlayerStateChangeListener(new PlayerStateChangeListener() {
@Override
public void onVideoStarted() {
}
@Override
public void onVideoEnded() {
}
@Override
public void onLoading() {
}
@Override
public void onLoaded(String mVideoId) {
String url = "http://www.youtube.com/watch?v=" + mVideoId
}
@Override
public void onError(ErrorReason reason) {
}
@Override
public void onAdStarted() {
}
});
}