I'm using the YouTube Android Player API and want to overlay a view on top of a YouTubePlayerFragment
in order to display contextual information and controls above the playing video.
Unfortunately it seems playback does not work correctly in either a YouTubePlayerFragment
or YouTubePlayerView
whenever a there is one or more views stacked above the player in the layout hierarchy. Playback occurs for less than half a second before immediately pausing.
The issue can be reproduced by using the following layout for the Simple PlayerFragment demo that ships with the SDK:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:name="com.google.android.youtube.player.YouTubePlayerFragment"
android:id="@+id/youtube_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_alignParentTop="true"
android:text="@string/playerfragment_text"/>
</RelativeLayout>
I have tried various layout configurations using both FrameLayout
and RelativeLayout
but the issue is always the same. I realise this API has been released as "experimental", but if this is a known issue it is a pretty major blocker for a lot of implementations. Does anyone have a good solution or workaround?
Jeff - this works as designed. Overlays on top of any of our YouTube players (including the YouTube Android Player) are not supported. When an overlay is detected, playback stops and the log contains information helpful in debugging the issue. We do support Action Bar overlays, take a look at this demo to learn more: https://developers.google.com/youtube/android/player/sample-applications#Overlay_ActionBar_Demo.