18

Fragment 内で YouTubePlayer (Android 用の YouTube API) を使用しています。次のように、YouTube Player で LinearLayout を膨らませています。

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

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

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

これは私の 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>

マージンを変更しようとしましたが成功しませんでした。公式ドキュメントを読みましたが、成功しませんでした問題の原因となっている FrameLayout は次のとおりです: android.widget.FrameLayout @ 4110d1f8

誰かに彼はこれが起こったのですか?

助けていただければ幸いです。

よろしく

4

8 に答える 8

19

今日も同じ問題に直面しました。ログのエラーは次のとおりです。

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 のパディングを削除して、これを修正しました。したがって、私のレイアウトは次のようになります。

<com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/video_player"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000" />
于 2015-04-16T13:38:39.643 に答える
7

同じエラーが発生しました。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..

フルスクリーンを設定した後、完璧に機能しました

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

それが他の人を助けることを願っています。

于 2017-09-04T09:49:42.060 に答える
5

問題はレイアウトにのみあり、YouTube Playerビューがその上にとどまることは許可されず、非表示でも透明でもありません。

これをデバイスで表示するには、開発者向けオプションでレイアウトの境界を有効にします。(paddingsと の警告margins)

レイアウト上の他のビューのコードをコメントアウトして、これをもう一度テストしてください。

于 2013-12-08T20:29:42.873 に答える