YouTubeAndroidPlayerAPI在Android.?

时间:2018-04-09 13:51:49

标签: android youtube youtube-api

我遇到了这样的问题

  

W / YouTubeAndroidPlayerAPI:强制创建叠加:acqm @ 6b45523助手:懒惰@ 8cb1a20查看:null状态:....... {...}

> W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor android.support.v7.widget.RecyclerView{d1a0545 VFED.V... .F...... 0,0-1080,1554 #7f0e007b app:id/details_recyclerview}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: -48, right: 0, bottom: 1002 (these should all be positive).

在Recycleview

中实施

问题:当用户进入屏幕时,第一次工作正常,当用户在背景中向上和向下滚动视频但在视频顶部显示黑屏时

activity_main.xml中

 <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

<include layout="@layout/header_navigation" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/header"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/details_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white_color"
        android:scrollbars="vertical">

    </android.support.v7.widget.RecyclerView>

    </LinearLayout>
 </RelativeLayout>

my recycle item.xml

      <?xml version="1.0" encoding="utf-8"?>
       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

<com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/youtube_video_player"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="@color/article_details_background"
    android:visibility="visible"></com.google.android.youtube.player.YouTubePlayerView>

<ScrollView
    android:id="@+id/scrollview_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/youtube_video_player"
    android:visibility="gone">

    <RelativeLayout
        android:id="@+id/relativelayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <FrameLayout
            android:id="@+id/artical_image_layout"
            android:layout_width="match_parent"
            android:layout_height="200dp">


            <ImageView
                android:id="@+id/article_details_background_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/article_details_background"
                android:scaleType="fitCenter" />

            <include
                layout="@layout/article_view_details"
                android:visibility="gone" />

        </FrameLayout>             
    </RelativeLayout>
</ScrollView>
 </LinearLayout>

1 个答案:

答案 0 :(得分:1)

正如您可以在错误消息中看到的那样,您不允许将任何视图叠加到YouTube播放器上,您是否尝试在播放器关闭时暂停播放?

如果你有兴趣,我一直在建立一个图书馆以避免这类问题,android-youtube-player。这将使您可以更自由地使用播放器。