【问题标题】:Youtubesupportfragment player is not working on re initializing the youtube player with new videoYoutubesupportfragment 播放器无法使用新视频重新初始化 youtube 播放器
【发布时间】:2017-02-27 14:03:34
【问题描述】:
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by com.google.android.youtube.player.YouTubePlayerView{b5323ed V.E...... ........ 0,0-680,382}. YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 0, right: 0, bottom: 0..

我已经提到了我在使用新的 youtube 视频 url 重新初始化 youtube 片段时遇到的上述错误。

到目前为止,我已经在 youtube 播放器上方使用了一个视图,并根据播放器状态将其设置为隐藏或可见,并且它是第一次工作,但是当我使用新的 youtube url 重新加载时,它在 2 秒后无法播放。

我已经发布了我的布局代码自爆

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent">

    <FrameLayout
        android:id="@+id/youtube_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/blue"
        />

    <ImageView
        android:layout_width="@dimen/dimen_size_40dp"
        android:layout_height="@dimen/dimen_size_40dp"
        android:layout_alignParentEnd="true"
        android:scaleType="centerInside"
        android:layout_gravity="end"
        android:src="@drawable/ic_mode_edit_white_48" />

</RelativeLayout>

谁能告诉我我做错了什么?

【问题讨论】:

  • 您可以参考这个related SO thread。尝试在布局中删除 YouTubePlayerView 中的填充。您还可以检查这是否是特定于设备的isue,这可能是由于透明视图与 YouTubeAndroidPlayer 视图重叠。
  • @abielita 我已经编辑发布并添加了布局代码,请检查它。我没有为布局添加任何边距,但根容器的填充为 16dp

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


【解决方案1】:

请勿在 youtubeview 或片段之上覆盖任何视图。只需给您的 imageview 一些上边距,或者您可以在 imageview 标记内使用 layout_below 属性。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">

<FrameLayout
    android:id="@+id/youtube_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/blue"
    />

<ImageView
    android:layout_width="@dimen/dimen_size_40dp"
    android:layout_height="@dimen/dimen_size_40dp"
    android:layout_alignParentEnd="true"
    android:scaleType="centerInside"
    android:layout_gravity="end"

    android:layout_below="youtube_layout"  // added this line

    android:src="@drawable/ic_mode_edit_white_48" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-03
    • 2014-05-01
    • 1970-01-01
    • 2012-04-02
    • 2014-09-27
    • 2015-02-16
    • 2013-05-23
    • 1970-01-01
    相关资源
    最近更新 更多