由于在全屏视图中未经授权覆盖播放器顶部,YouTube视频播放停止

时间:2017-04-19 11:55:15

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

在我的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示例。

但是我的应用程序没有按预期工作,就像示例中的demo show一样。我面临的问题是,当我切换到全屏视图时,它完美地工作直到我触摸屏幕并且状态栏和导航栏都悬停在播放器上方并在一段时间后停止播放器说出此错误:

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..

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

1 个答案:

答案 0 :(得分:-1)

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