【问题标题】:Video pausing with error "Unauthorized overlay"视频暂停并出现错误“未经授权的叠加”
【发布时间】:2015-07-26 15:44:51
【问题描述】:

在全屏模式下播放视频时出现以下错误(仅在全屏模式下)。我在全屏时隐藏了布局中的所有其他组件,但它说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);

【问题讨论】:

  • 你能详细说明一下全屏部分吗?您使用的是什么 API?
  • 在有关我正在使用的 API 的问题中添加了更多详细信息。

标签: android youtube-api android-youtube-api


【解决方案1】:

取自documentation

FULLSCREEN_FLAG_CUSTOM_LAYOUT 禁用默认全屏布局处理程序,使您能够手动控制到全屏布局的转换。

如您所见,设置该标志留给您处​​理 UI 元素可见性的任务,尤其是那些属于系统 UI(状态栏、导航栏)的元素。

因此,如果您未能隐藏状态栏,YouTube 播放器将检测到正在其上方显示视图,因此会发出警告。


您可以尝试使用以下附加标志之一

FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE:使播放器在设备进入横向时自动进入全屏模式。

FULLSCREEN_FLAG_CONTROL_ORIENTATION:启用方向的自动控制。

FULLSCREEN_FLAG_CONTROL_SYSTEM_UI:启用系统 UI 的自动控制。

FULLSCREEN_FLAG_CUSTOM_LAYOUT:禁用默认的全屏布局处理程序,使您能够手动控制转换到全屏布局。

或者,如果您确实需要手动控制系统 UI,请继续使用自定义布局标志并确保处理 UI 元素的可见性。

【讨论】:

  • 谢谢。我现在隐藏状态栏,它正在工作。
  • 嗨,我也有类似的问题。你能告诉我在播放器全屏时如何处理导航栏吗?请在stackoverflow.com/questions/35909260/…查看我的问题。
  • 我遇到了类似的问题。我保留了 FULLSCREEN_FLAG_CUSTOM_LAYOUT 并应用了这个答案stackoverflow.com/a/33705740/4391398。视频现在可以在方向更改为横向时以全屏方式完美播放。谢谢塞巴斯蒂亚诺
猜你喜欢
  • 2018-04-16
  • 2023-03-05
  • 2014-03-08
  • 2017-09-15
  • 1970-01-01
  • 2021-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多