Я хочу, чтобы в моем приложении отображался экран, связанный с видео YouTube.Итак, как настроить YouTubePlayerView для отображения конечных экранов в приложении Android.Ниже приведен код, используемый для воспроизведения видео YouTube в моем приложении
youTubePlayerView.initialize(new Keys().YTKey(), new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored)
{
// Defining player
player = youTubePlayer;
// Setting flag for the player to play video in fullscreen mode when switched to landscaper orientation
player.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION | YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
// Checking whether video is restored or not
if (!wasRestored)
{
// If not restored load video
player.loadVideo(videoId);
player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
}
else
{
// Else play the restored video
player.play();
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
Toast.makeText(getBaseContext(), "Failed to Initialize Player", Toast.LENGTH_LONG).show();
}
});