YouTubePlayer 没有播放视频

YouTubePlayer isn't playing a video

我使用 YouTubePlayerSupportFragment 播放 YouTube 视频,但它播放了 2 或 3 秒后自动停止。我找不到问题所在。

下面是我的片段翻译代码

    mYoutubePlayerFragment = new YouTubePlayerSupportFragment();
            mYoutubePlayerFragment.initialize(
                    "key",
                    mListnnerYouTube);
            FragmentManager fragmentManager = getChildFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            fragmentTransaction.replace(R.id.fragment_youtube_player,
                    mYoutubePlayerFragment);
            fragmentTransaction.commit();

和我的 onInitializationSuccess

@Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer player,
        boolean wasRestored) {
    // TODO Auto-generated method stub
    activeplayer = player;
    activeplayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
    if (!wasRestored) {
        // player.cueVideo("nCgQDjiotG0");
        player.loadVideo("nCgQDjiotG0");
    }

我在片段中使用了 YouTubePlayerSupportFragment

错误信息

YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by com.viewpagerindicator.CirclePageIndicator{420b9758 V.ED.... ......I. 0,412-720,465 #7f0a005c app:id/indicator}. The view is inside the YouTubePlayerView, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 412, right: 0, bottom: 0..

您很可能在播放器视图顶部显示了某些内容,这是 YouTube SDK 禁止的。

检查日志,您应该会看到来自 YouTube SDK 的警告,说明视频播放停止的原因。如果 View 覆盖了播放器的一部分,日志将指定其 ID 及其在屏幕上的位置。