安卓YouTubePlayer与播放器上未经授权的叠加

安卓YouTubePlayer与播放器上未经授权的叠加

本文介绍了安卓YouTubePlayer与播放器上未经授权的叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是片段中YouTubePlayer(YouTube的API Android版)我膨胀与YouTube播放器一个LinearLayout中,以这种方式:

I'm using YouTubePlayer (YouTube api for android) within a FragmentI am inflating a LinearLayout with the YouTube Player, in this way:

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

                    player = new YouTubePlayerSupportFragment();
                    fragmentTransaction.add(R.id.youTubePlayerContainer, player);
                    fragmentTransaction.commit();

...其中youTubePlayerContainer是膨胀的LinearLayout

...Where youTubePlayerContainer is the inflated LinearLayout

的选手正确地检测到,开始播放,并在第二站。日志显示以下内容:

The player is detected correctly, start playing and in a second stops.The Log shows the following:

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..

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

This is my XML:(No FrameLayout within it)

 <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>

我试图改变利润没有成功。我读了官方文件,但没有成功指示引起该问题的FrameLayout是:android.widget.FrameLayout @ 4110d1f8但这样的参考并不识别其是指

I tried changing the margins without success.I read the official documentation but without successIndicates that the FrameLayout that causes the problem is: android.widget.FrameLayout @ 4110d1f8But with such a reference does not identify which refers

的人,他会出现这种情况?

to someone he did this happen?

我AP preciate任何帮助。

I appreciate any help.

问候

推荐答案

您是否能够解决这个问题?

Were you able to solve this problem?

我今天所面临的同样的问题,我在日志中的错误是:

I faced the same problem today, and for me the error in the logs was:

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).

我通过除去在YouTubePlayerView填充在布局固定这一点。所以,我的布局是这样的:

I fixed this by removing the padding in the YouTubePlayerView in the layout. So my layout looks like this:

<com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/video_player"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000" />

这篇关于安卓YouTubePlayer与播放器上未经授权的叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:33