Android YouTubePlayer with unauthorized overlay on top of player

后端 未结 8 1894
慢半拍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:56

    The problem is only with layout, the YouTube Player doesn't permit any view staying over it, neither invisible nor transparent.

    In order to make this visible in your device, enable layout bounds in developer option.(warning with paddings and margins)

    Try to comment out others views' code on your layout and test this again please.

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

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

    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" />
    
    0 讨论(0)
提交回复
热议问题