【发布时间】:2016-05-17 09:31:53
【问题描述】:
我在我的应用程序中使用适用于 Android 的 Youtube Api,并在我的活动中创建新的 YouTubePlayerView 动态,例如:
YouTubePlayerView youTubePlayerView = new YouTubePlayerView(PlayerActivity.this);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(640, 360);
layoutParams.setMargins(100, 200, 0, 0);
youTubePlayerView.setLayoutParams(layoutParams);
root.addView(youTubePlayerView);
如代码,“root”是一个RelativeLayout,youTubePlayerView的大小和margin因每个youTubePlayerView而异;
此代码有时有效,但有时无效,它返回以下错误:
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{37ab2582 V.E..... ......ID 0,0-0,0}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: 0, right: 0, bottom: 0 (these should all be positive).
或者这个
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to the player's view being too small. The YouTubePlayerView is 0dp wide (minimum is 200dp) and 0dp high (minimum is 110dp).
有什么办法可以避免它发生,或者让它成功播放视频。
感谢您的帮助。
问候
【问题讨论】:
-
您还遇到这个问题吗?
-
你找到解决办法了吗?
标签: android youtube-api