Android YouTubePlayer with unauthorized overlay on top of player

后端 未结 8 1881
慢半拍i
慢半拍i 2020-11-29 09:53

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

fragmentManager = ge         


        
相关标签:
8条回答
  • 2020-11-29 10:35

    I had the same error. Although I did the XML changes, I continued to receive the error:

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

    After I set the FULLSCREEN, it worked perfect

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

    Hope it will help others.

    0 讨论(0)
  • 2020-11-29 10:40

    You have to remove any padding attribute in the Video view.

    Wrong:

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="vertical" >
    
       <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        **android:padding="10dp"** />
    
        </LinearLayout>
    

    Right:

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />
    
        </LinearLayout>
    
    0 讨论(0)
  • 2020-11-29 10:44
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/id_base_layout"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent"
    android:background="#000000">
    
    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_view"
        android:layout_width="match_parent"
        android:layout_centerInParent="true"
        android:layout_height="wrap_content"  />
    

    1.add fitSystemWindows. 2.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    0 讨论(0)
  • 2020-11-29 10:44

    I faced the same problem while play video in youtubeplayer

    when I Add this line ...It's Work for me

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    0 讨论(0)
  • 2020-11-29 10:47

    Youtube Player find out some views overlay it. Just remove those view or setVisible(View.GONE) for them. Please check this link for more information Solution

    0 讨论(0)
  • 2020-11-29 10:52

    The demo code for the Android API uses this layout for the Fragment demo, maybe that can get ideas going. See this page: https://developers.google.com/youtube/android/player/

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
      <TextView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:textAppearance="@android:style/TextAppearance.Small"
          android:gravity="center"
          android:text="@string/playerfragment_text"/>
    
      <fragment
          android:name="com.google.android.youtube.player.YouTubePlayerFragment"
          android:id="@+id/youtube_fragment"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/>
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题