gpt4 book ai didi

android - YouTubePlayerFragment:由于播放器顶部未经授权的覆盖,导致YouTube视频播放停止

转载 作者:行者123 更新时间:2023-12-03 05:44:58 24 4
gpt4 key购买 nike

我正在尝试使用YouTube API在viewpager中播放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).

我无法解决问题,因为没有 View 遮挡框架布局。
布局文件为:
<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>

如果我删除外部布局并仅播放framelayout,仍然会出现错误。

最佳答案

在Android中,当您使用YouTube API时,视频必须位于屏幕顶部,而无需使用YoutubePlayerFragmentYoutubePlayerActivity。如果不是这样,API会引发类似您的错误。

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

希望对您有帮助,

关于android - YouTubePlayerFragment:由于播放器顶部未经授权的覆盖,导致YouTube视频播放停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36526832/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com