我使用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);

          }
     }

因此,请指导我如何实现这一目标。谢谢

最佳答案

您可以在AndroidManifest.xml中为youtube Activity 进行手动configChanges,如下所示:

android:configChanges="orientation|keyboardHidden|screenSize"

关于android - Youtube Player全屏控件在android中不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21260500/

10-12 01:24