0
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by com.google.android.youtube.player.YouTubePlayerView{b5323ed V.E...... ........ 0,0-680,382}. YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 0, right: 0, bottom: 0..

I have mentioned the error above that I'm facing when I re-initializing the youtube fragment with new youtube video url.

so far I have used a view above youtube player and make it as hide or visible based on the player state and it's working for first time but when i reload with new youtube url it's fails to play after 2 seconds.

I have posted my layout code blew

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent">

    <FrameLayout
        android:id="@+id/youtube_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/blue"
        />

    <ImageView
        android:layout_width="@dimen/dimen_size_40dp"
        android:layout_height="@dimen/dimen_size_40dp"
        android:layout_alignParentEnd="true"
        android:scaleType="centerInside"
        android:layout_gravity="end"
        android:src="@drawable/ic_mode_edit_white_48" />

</RelativeLayout>

Anyone please let me know what I have done it wrong way?

Somasundaram NP
  • 1,018
  • 1
  • 12
  • 36
  • You may refer with this [related SO thread](http://stackoverflow.com/a/29676512/5832311). Try removing the padding in the YouTubePlayerView in the layout. You may also check if this is device specific [isue](http://stackoverflow.com/questions/27834351/the-youtubeplayerview-is-obscured-by-com-lbe-security-service-core-client-a-f/29765413#29765413) which might be due to a transparent view is overlapping YouTubeAndroidPlayer view. – abielita Feb 28 '17 at 08:52
  • @abielita I have edited posted and added the layout code, please check it. I have not added any margin to layout but the root container has padding as 16dp – Somasundaram NP Feb 28 '17 at 10:32

1 Answers1

0

DO not overlay any view on top of youtubeview or fragments. Just give some top margin to your imageview or you can use layout_below property inside imageview tag.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">

<FrameLayout
    android:id="@+id/youtube_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/blue"
    />

<ImageView
    android:layout_width="@dimen/dimen_size_40dp"
    android:layout_height="@dimen/dimen_size_40dp"
    android:layout_alignParentEnd="true"
    android:scaleType="centerInside"
    android:layout_gravity="end"

    android:layout_below="youtube_layout"  // added this line

    android:src="@drawable/ic_mode_edit_white_48" />

Amit Sharma
  • 645
  • 5
  • 13