【问题标题】:YouTubePlayerFragment: YouTube video playback stopped due to unauthorized overlay on top of playerYouTubePlayerFragment:YouTube 视频播放因播放器顶部未经授权的覆盖而停止
【发布时间】:2016-07-31 07:47:31
【问题描述】:

我正在尝试使用 YouTube API 在浏览器中播放 YouTube 视频。我的片段由一个 FrameLayout 组成,我在其中播放视频。视频正在加载,但我一播放就停止。 错误日志如下:

W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.widget.LinearLayout{ffe4270 V........ ........ 5425,0-6505,1437 #7f0e00cd app:id/root}. YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 0, right: 0, bottom: 830..
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor android.support.v4.view.ViewPager{d17b08c VFED..... ......I. 0,210-1080,1794 #7f0e0089 app:id/viewPager}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 1085, top: 0, right: -1085, bottom: 830 (these should all be positive).

我无法找出问题所在,因为没有视图会遮挡框架布局。 布局文件是:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- Youtube fragment -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/youtube_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:visibility="visible" />
<!--android:name="com.google.android.youtube.player.YouTubePlayerFragment"-->
</linearLayout>

如果我删除外部布局并只播放框架布局,它仍然会出错。

【问题讨论】:

  • 你是怎么解决这个问题的。请分享您的解决方案。

标签: android video youtube youtube-api


【解决方案1】:

在 Android 中,当您使用 YouTube API 时,视频必须位于屏幕顶部,既不能使用 YoutubePlayerFragment,也不能使用 YoutubePlayerActivity。如果不是,API 会引发像您这样的错误。

有了这段代码,我不能说得这么具体,但我想有一个布局覆盖了你的 YoutubePlayerFragment,这是原因,因为你看到了错误。

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2018-08-29
    • 2018-08-30
    • 2018-04-16
    • 2015-04-10
    • 2017-05-19
    • 2013-04-10
    • 2017-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多