布局树
YouTubeBaseActivity
└ ConstraintLayout
└ ViewPager
├ LinearLayout
│ └ SwipeRefreshLayout
│ └ RecyclerView
│ └ ConstraintLayout
│ └ FrameLayout
│ └ **YouTubePlayerView**
│
└ LinearLayout
└ SwipeRefreshLayout
└ RecyclerView
└ ConstraintLayout
// There is only YTPlayerView on the first page
初始化
youTubeView.initialize(activity.getString(R.string.google_api_key), new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.cueVideo("792WRHqbpE4");
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
});
当我在1-2秒钟后按PLAY按钮时,它将自动暂停。
答案 0 :(得分:1)
读取logcat中的错误,您无法将任何视图与YouTubePlayerView重叠。
为克服YouTube Player API的这些限制,我构建了一个开源YouTube播放器,它也可能对您有所帮助。 android-youtube-player