我想用导航抽屉强制使用YouTubePlayerSupportFragment,但我收到了错误消息 YouTube视频播放因播放器顶部未经授权的覆盖而停止。 facebook.support.v4.app.NoSaveStateFrameLayout@213d7588隐藏了YouTubePlayerView。 YouTubePlayerView完全覆盖,隐藏视图的每个边缘与YouTubePlayerView之间的距离为px:left:0,top:70,right:0,bottom:714 ..
YouTubePlayerSupportFragment mYoutubePlayerFragment = new YouTubePlayerSupportFragment();
mYoutubePlayerFragment.initialize(
"Youtube Key",
new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(Provider arg0,
YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.loadVideo(newPost.get("url").toString());
player.play();
}
}
@Override
public void onInitializationFailure(Provider arg0,
YouTubeInitializationResult result) {
if (result.isUserRecoverableError()) {
result.getErrorDialog(getActivity(), 1).show();
} else {
Toast.makeText(
getActivity(),
"YouTubePlayer.onInitializationFailure(): "
+ result.toString(),
Toast.LENGTH_LONG).show();
}
}
});
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
fragmentTransaction.replace(R.id.youtube_fragment,
mYoutubePlayerFragment);
fragmentTransaction.commit();
}
答案 0 :(得分:0)
来自ducumentation youtube播放器shoudbe topest元素,并具有200 * 110 dp的最小尺寸。如果它更小 - 玩家将停止。如果任何视图(甚至不可见)将与youtube播放器重叠 - 播放器将停止