我想在片段中播放 youtube 播放器,但我不明白如何使用片段扩展 youtube 基本活动,该播放器在活动上正确工作,但我想在片段中播放
VideoPlayer extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener
youTubePlayerView.initialize(String.valueOf(R.string.youtubeapi), VideoPlayer.this);
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
Toast.makeText(this, "Initialized Youtube Player successfully", Toast.LENGTH_LONG).show();
youTubePlayer.setPlayerStateChangeListener(playerStateChangeListener);
youTubePlayer.setPlaybackEventListener(playbackEventListener);
if(!wasRestored) {
youTubePlayer.cueVideo(url);
}
}
private YouTubePlayer.PlaybackEventListener playbackEventListener = new
YouTubePlayer.PlaybackEventListener() {
@Override
public void onPlaying()
}
@Override
public void onPaused() {
Toast.makeText(VideoPlayer.this,"Video has paused", Toast.LENGTH_LONG).show();
}
<com.google.android.youtube.player.YouTubePlayerView
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/youtubeplayer"
/>