Android YouTubePlayer未经授权覆盖在播放器上方

Ser*_*o76 17 android youtube-api android-framelayout

我在片段中使用YouTubePlayer(Android api for android)我正在使用YouTube播放器为LinearLayout充气,这样:

fragmentManager = getActivity().getSupportFragmentManager();
                    fragmentTransaction = fragmentManager.beginTransaction();

                    player = new YouTubePlayerSupportFragment();
                    fragmentTransaction.add(R.id.youTubePlayerContainer, player); 
                    fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)

... youTubePlayerContainer是膨胀的LinearLayout

正确检测到播放器,开始播放并在第二站停止播放.日志显示以下内容:

YouTube video playback stopped due to unauthorized overlay on top of player. 
The YouTubePlayerView is obscured by android.widget.FrameLayout@4110d1f8. 
YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 484, top: 100, right: 100, bottom: 170..
Run Code Online (Sandbox Code Playgroud)

这是我的XML :(其中没有FrameLayout)

 <LinearLayout
        android:id="@+id/curtain"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/withApi"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/youTubePlayerContainer"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_gravity="center"
                android:layout_margin="30dp"
                android:layout_weight="1"
                android:orientation="vertical" >
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="3dp"
                android:background="@color/trans_popUp"
                android:padding="3dp" >

                <TextView
                    android:id="@+id/textYouTubeVisor"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Title..."
                    android:textColor="@color/white" />
            </LinearLayout>
        </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我尝试改变边距但没有成功.我阅读官方文档但没有成功表示导致问题的FrameLayout是:android.widget.FrameLayout @ 4110d1f8但是这样的引用不能识别哪个引用

他这样做的人会这样吗?

我感谢任何帮助.

问候

Bon*_*255 17

你能解决这个问题吗?

我今天遇到了同样的问题,对我来说日志中的错误是:

W/YouTubeAndroidPlayerAPI? YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 V.E..... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10, top: -10, right: -10, bottom: -10 (these should all be positive).
Run Code Online (Sandbox Code Playgroud)

我通过删除布局中的YouTubePlayerView中的填充来修复此问题.所以我的布局看起来像这样:

<com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/video_player"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000" />
Run Code Online (Sandbox Code Playgroud)


luc*_*iel 5

问题仅在于布局,YouTube Player不允许任何视图停留在其上,既看不见也不透明。

为了使它在您的设备中可见,请在开发人员选项中启用布局边界。(paddings和警告margins)。

尝试在您的布局上注释掉其他视图的代码,然后再次进行测试。


Igo*_*man 5

我有同样的错误。尽管我做了XML更改,但仍然收到错误消息:

 YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.view.View{59fa6ce V.ED..... ........ 0,0-1440,84 #102002f android:id/statusBarBackground}. 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: 0, right: 0, bottom: 2308..
Run Code Online (Sandbox Code Playgroud)

在我设置FULLSCREEN之后,它可以完美工作

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)

希望它能帮助别人。