0

I am trying Custom youtupeplayerView in android.

I am using FrameLayout inside android YouTubePlayerView. For purpose youtube control(play/pause, SeekBar forward/backward) customization. Youtubeplayerview video is loading but suddenly the player has paused the video. why? The video does not continue to play the player

below add XML code

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">
    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/demo_youtubeplayer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="vertical">
    <TextView
        android:id="@+id/water_mark"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center"
        android:layout_marginLeft="30dp"
        android:alpha="0.50"
        android:padding="5dp"
        android:text="@string/water_mark"
        android:textColor="#66ffffff"
        android:textSize="20dp" />
</LinearLayout>

<LinearLayout
    android:id="@+id/video_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="@android:color/transparent"
    android:gravity="center_vertical"
    android:orientation="vertical">
    <TextView
        android:id="@+id/youtubeview_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:padding="15dp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@android:color/white" />
</LinearLayout>

<LinearLayout
    android:id="@+id/video_control"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@android:color/transparent"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/youtube_playimg"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@null"
        android:src="@drawable/ic_media_play" />

    <!--<ImageView
        android:id="@+id/pause_video"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@null"
        android:src="@drawable/ic_media_pause" />-->

    <SeekBar
        android:id="@+id/video_seekbar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="6"
        android:max="100"
        android:progress="0" />

    <TextView
        android:id="@+id/play_timetv"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="2"
        android:text="--:--"
        android:textColor="@android:color/white" />
</LinearLayout>

below add Screenshot

play/pause and SeekBar use FrameLayout overlay screen

Community
  • 1
  • 1
Sakthi Vel
  • 106
  • 1
  • 5

1 Answers1

0

according to youtube android sdk guidelines, no other view should overlay youtube player, in your xml other views are above youtube player

public static final YouTubePlayer.ErrorReason UNAUTHORIZED_OVERLAY Playback has been stopped due to a view overlaying the player. It is not permitted to overlay views on top of the player while it is playing video.

When this error is reported, a message will be printed in the device log with information about which view is overlaying the player and the location of the overlap.

https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayer.ErrorReason