Android YouTubePlayer,未经授权的重叠式播放器

前端之家收集整理的这篇文章主要介绍了Android YouTubePlayer,未经授权的重叠式播放器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在片段中使用YouTubePlayer( Android API的YouTube api)
我通过YouTube播放器向LinearLayout充气:
  1. fragmentManager = getActivity().getSupportFragmentManager();
  2. fragmentTransaction = fragmentManager.beginTransaction();
  3.  
  4. player = new YouTubePlayerSupportFragment();
  5. fragmentTransaction.add(R.id.youTubePlayerContainer,player);
  6. fragmentTransaction.commit();

…哪里youTubePlayerContainer是膨胀的LinearLayout

玩家被正确检测,开始播放,并在第二站.
日志显示以下内容

  1. YouTube video playback stopped due to unauthorized overlay on top of player.
  2. The YouTubePlayerView is obscured by android.widget.FrameLayout@4110d1f8.
  3. YouTubePlayerView is completely covered,with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 484,top: 100,right: 100,bottom: 170..

这是我的XML:
(其中没有FrameLayout)

  1. <LinearLayout
  2. android:id="@+id/curtain"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. <LinearLayout
  8. android:id="@+id/withApi"
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:orientation="vertical" >
  12.  
  13. <LinearLayout
  14. android:id="@+id/youTubePlayerContainer"
  15. android:layout_width="match_parent"
  16. android:layout_height="0dp"
  17. android:layout_gravity="center"
  18. android:layout_margin="30dp"
  19. android:layout_weight="1"
  20. android:orientation="vertical" >
  21. </LinearLayout>
  22.  
  23. <LinearLayout
  24. android:layout_width="match_parent"
  25. android:layout_height="wrap_content"
  26. android:layout_margin="3dp"
  27. android:background="@color/trans_popUp"
  28. android:padding="3dp" >
  29.  
  30. <TextView
  31. android:id="@+id/textYouTubeVisor"
  32. android:layout_width="wrap_content"
  33. android:layout_height="wrap_content"
  34. android:text="Title..."
  35. android:textColor="@color/white" />
  36. </LinearLayout>
  37. </LinearLayout>

我试着改变利润,没有成功.
我正在阅读官方文件,但没有成功
表示导致问题的FrameLayout是:android.widget.FrameLayout @ 4110d1f8
但是有了这样一个参考,并不能确定哪一个是指的

对他这样做的人呢?

我感谢任何帮助.

问候

解决方法

你能解决这个问题吗?

我今天遇到同样的问题,对我而言,日志中的错误是:

  1. W/YouTubeAndroidPlayerAPI YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 V.E..... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10,top: -10,right: -10,bottom: -10 (these should all be positive).

我通过删除布局中的YouTubePlayerView中的填充来修复此问题.所以我的布局看起来像这样:

  1. <com.google.android.youtube.player.YouTubePlayerView
  2. android:id="@+id/video_player"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:background="#000" />

猜你在找的Android相关文章