我使用YoutubePlayerFragment播放视频,但是当我点击全屏控制选项时,屏幕会旋转到横向模式并显示未找到视图的异常。
**i am using the following logic:**
Fragment fragment = new YouTubePlayerFragment();
FragmentManager fm = getActivity().getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.youtubeplayerview, fragment);
ft.commit();
YouTubePlayerFragment youtubeFrag = (YouTubePlayerFragment) fragment;
youtubeFrag.initialize(API_KEY, this);
@Override
public void onInitializationFailure(Provider arg0,
YouTubeInitializationResult arg1) {
// TODO Auto-generated method stub
}
@Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer player,
boolean wasRestored) {
if (!wasRestored) {
this.playe=player;
playe.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);
playe.loadVideo(videoid,starttime);
}
}
所以,请指导我如何实现这一目标。谢谢
答案 0 :(得分:3)
您可以在AndroidManifest.xml中为youtube活动执行手动configChanges,如下所示:
android:configChanges="orientation|keyboardHidden|screenSize"