我在youtubeplayerview上有一项活动。为什么我点击视图上的全屏按钮,视频不会旋转。而是显示空白屏幕。
我的代码如下:
youtube = (YouTubePlayerView)findViewById(R.id.youtube_view1);
youtube.initialize("APP_ID",this);
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer youTubePlayer, boolean b) {
if (!b) {
if(deeplink == false) {
youTubePlayer.loadVideo(youtube_ID);
}
else
{
youTubePlayer.loadVideo(youtube_ID_deeplink);
}
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
我无法理解我哪里出错了。请建议。
答案 0 :(得分:1)
在活动代码中的清单文件中添加
android:configChanges="keyboardHidden|orientation|screenSize"
像这样
<activity
android:label="ActivityName"
android:configChanges="keyboardHidden|orientation|screenSize"
android:name="com.example.app.ActivityName" />
答案 1 :(得分:0)
试试此代码段
youTubePlayerSupportFragment.initialize(API_KEY, new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
youTubePlayer.loadVideo(Uri.parse(mVideosList.get(position).getLink()));
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult youTubeInitializationResult) {
System.out.println("onInitializationFailure");
}
});