视频暂停并显示错误“未经授权的覆盖" [英] Video pausing with error "Unauthorized overlay"
问题描述
在全屏模式(仅在全屏模式)下播放视频时,出现以下错误.当全屏显示时,我将布局中的所有其他组件隐藏起来,但是它表示android:id/statusBarBackground
是导致问题的视图.我该如何控制?
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.view.View{16771a9d V.ED.... ........ 0,0-1920,75 #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: 1005..
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/videoListLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/heading" >
<TextView
android:id="@+id/topDisplayArea"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/app_desc"
android:textColor="@color/topDisplayAreaFG"
android:textSize="18sp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true" >
<ImageButton
android:id="@+id/mp_shareCommonButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/widget_button"
android:contentDescription="Share"
android:cropToPadding="true"
android:src="@android:drawable/ic_menu_preferences" >
</ImageButton>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/infoPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/retrievalProgressIndicator"
style="?android:attr/progressBarStyle"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:indeterminate="true" />
<TextView
android:id="@+id/refreshContentLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Connecting to server..."
android:textColor="@color/topDisplayAreaFG"
android:textSize="18sp"
android:typeface="sans" >
</TextView>
</LinearLayout>
<fragment
class="VideosActivity$VideoListFragment"
android:id="@+id/list_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/video_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<ImageButton
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@android:drawable/btn_dialog"
android:onClick="onClickClose"/>
<fragment
class="VideosActivity$VideoFragment"
android:id="@+id/video_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</merge>
我正在使用FullScreenListener,并且在onFullScreen函数中,我隐藏了除视频片段以外的所有其他元素.
@Override
public void onFullscreen(boolean isFullscreen) {
this.isFullscreen = isFullscreen;
layout();
}
我还要在视频播放器中添加以下标志
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
来自 FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE
:每当设备进入横向时,播放器都会自动进入全屏模式.
FULLSCREEN_FLAG_CONTROL_ORIENTATION
:可以自动控制方向.
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI
:启用系统UI的自动控制.
FULLSCREEN_FLAG_CUSTOM_LAYOUT
:禁用默认的全屏布局处理程序,使您可以手动控制向全屏布局的过渡.
或者,如果您实际上需要手动控制系统UI,请继续使用自定义布局标志,并确保处理UI元素的可见性.
I am getting following error while playing video in fullscreen mode (only in fullscreen). I am hiding all other components in the layout when it goes fullscreen but it says that android:id/statusBarBackground
is the view that is causing the problem. How do I control that?
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.view.View{16771a9d V.ED.... ........ 0,0-1920,75 #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: 1005..
My layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/videoListLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/heading" >
<TextView
android:id="@+id/topDisplayArea"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/app_desc"
android:textColor="@color/topDisplayAreaFG"
android:textSize="18sp"
android:textStyle="bold"
android:typeface="serif" >
</TextView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true" >
<ImageButton
android:id="@+id/mp_shareCommonButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/widget_button"
android:contentDescription="Share"
android:cropToPadding="true"
android:src="@android:drawable/ic_menu_preferences" >
</ImageButton>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/infoPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/retrievalProgressIndicator"
style="?android:attr/progressBarStyle"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:indeterminate="true" />
<TextView
android:id="@+id/refreshContentLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Connecting to server..."
android:textColor="@color/topDisplayAreaFG"
android:textSize="18sp"
android:typeface="sans" >
</TextView>
</LinearLayout>
<fragment
class="VideosActivity$VideoListFragment"
android:id="@+id/list_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/video_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<ImageButton
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@android:drawable/btn_dialog"
android:onClick="onClickClose"/>
<fragment
class="VideosActivity$VideoFragment"
android:id="@+id/video_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</merge>
I am using FullScreenListener and in onFullScreen function, I hide all other elements in the layout except the videofragment.
@Override
public void onFullscreen(boolean isFullscreen) {
this.isFullscreen = isFullscreen;
layout();
}
Also I am adding following flag to the video player
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
Taken from the documentation
FULLSCREEN_FLAG_CUSTOM_LAYOUT
disables the default fullscreen layout handler, enabling you to control the transition to fullscreen layout manually.
As you see, setting that flag leaves to you the task of handling the UI elements' visibility, in particular those belonging to the System UI (status bar, navigation bar).
For this reason, if you fail to hide the status bar, the YouTube player will detect that a view is being displayed over it and will therefore throw that warning.
You can try with one of the following additional flags
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE
: causes the player to automatically enter fullscreen whenever the device enters landscape orientation.
FULLSCREEN_FLAG_CONTROL_ORIENTATION
: enables automatic control of the orientation.
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI
: enables automatic control of system UI.
FULLSCREEN_FLAG_CUSTOM_LAYOUT
: disables the default fullscreen layout handler, enabling you to control the transition to fullscreen layout manually.
or, if you actually need to have manual control over the System UI, keep using the custom layout flag and be sure to handle the UI elements' visibility.
这篇关于视频暂停并显示错误“未经授权的覆盖"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!