【问题标题】:YouTube video playback stopped due to unauthorized overlay on top of player in full screen view由于在全屏视图中播放器顶部出现未经授权的叠加,YouTube 视频播放停止
【发布时间】:2017-09-15 15:25:32
【问题描述】:

在我的 android 应用程序中,我正在开发 YouTube 播放器,我正在播放我频道中的 YouTube 视频。我的玩家活动有这个配置

<activity android:name=".videos.videoplayer.VideoPlayerActivity"
        android:screenOrientation="sensor"
        android:configChanges="keyboardHidden|orientation|screenSize"/>

我的活动布局在这里

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/coordinatorLayout"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize"
    android:id="@+id/appbarLayout"
    android:background="@color/appbar_color">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/toolbar"
        app:layout_scrollFlags="scroll|enterAlways">
        <include layout="@layout/custom_share_appbar"/>
    </RelativeLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/refresh_layout"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:orientation="vertical">
    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000"/>
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:id="@+id/feeds_content">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <com.beebom.app.beebom.customizeviews.Lato_Bold_TextView
                tools:context=".home.HomeActivity"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/video_title"
                android:text=""
                android:textColor="@color/black"
                android:textSize="@dimen/size_twenty_two_sp"
                android:lineSpacingExtra="@dimen/size_two_sp"
                android:layout_marginLeft="@dimen/size_sixteen_dp"
                android:layout_marginTop="@dimen/size_twenty_dp"
                android:layout_marginRight="@dimen/size_sixteen_dp"
                android:layout_marginBottom="@dimen/size_nine_dp"/>
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_below="@+id/video_title"
                android:id="@+id/author_details"
                android:layout_marginTop="@dimen/size_ten_dp"
                android:layout_marginLeft="@dimen/size_sixteen_dp"
                android:layout_marginBottom="@dimen/size_twelve_dp">
                <com.beebom.app.beebom.customizeviews.Lato_Regular_TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/video_published_date"
                    android:textColor="@color/black"
                    android:textSize="@dimen/size_forteen_sp"
                    android:textStyle="bold"
                    android:layout_marginRight="@dimen/size_eight_dp"
                    android:text=""/>
                <com.beebom.app.beebom.customizeviews.Lato_Bold_TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text=""
                    android:textSize="@dimen/size_twelve_sp"
                    android:textColor="@color/timecolor"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="@dimen/size_sixteen_dp"
                    android:layout_alignParentRight="true"
                    android:id="@+id/video_views"
                    />
            </RelativeLayout>
            <WebView
                android:id="@+id/webView"
                android:layout_below="@+id/author_details"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/size_four_dp"
                android:layout_marginRight="@dimen/size_sixteen_dp"
                android:layout_marginLeft="@dimen/size_sixteen_dp"/>
            <ProgressBar
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:visibility="gone"
                android:layout_margin="@dimen/size_fifteen_dp"
                android:id="@+id/progressBar" />
        </RelativeLayout>
    </android.support.v4.widget.NestedScrollView>
</LinearLayout>

我正在关注从 youtube 开发者网站下载的 youtube 示例。

但我的应用无法像示例中的演示那样按预期运行。我面临的问题是,当我切换到全屏视图时,它可以正常工作,直到我触摸屏幕并且状态栏和导航栏都悬停在播放器上方并在一段时间后停止播放器说这个错误:

W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.view.View{461d366 V.ED..... ........ 1794,0-1920,1080 #1020030 android:id/navigationBarBackground}. The view is inside the YouTubePlayerView, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 1794, top: 0, right: 0, bottom: 0..

如何解决此问题以及导致此问题的原因。

【问题讨论】:

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


【解决方案1】:

我遇到了同样的问题,解决方法是调整显示视频的窗口大小

【讨论】:

  • 如何调整手机窗口的大小?如果您在代码中讨论resize,请编写相应的命令。
猜你喜欢
  • 2018-04-16
  • 2018-08-29
  • 2018-08-30
  • 2016-07-31
  • 2017-05-19
  • 2015-04-10
  • 2020-04-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多