Layout tree
YouTubeBaseActivity
└ ConstraintLayout
└ ViewPager
├ LinearLayout
│ └ SwipeRefreshLayout
│ └ RecyclerView
│ └ ConstraintLayout
│ └ FrameLayout
│ └ **YouTubePlayerView**
│
└ LinearLayout
└ SwipeRefreshLayout
└ RecyclerView
└ ConstraintLayout
// There is only YTPlayerView on the first page
Initialize
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) {
}
});
When i press the PLAY button after 1~2 seconds, it will be paused automatically.
Read the error in logcat, you can't overlap any view with YouTubePlayerView.
To overcome these limitations of the YouTube Player API I've built an opensource YouTube player, it may be helpful to you as well. android-youtube-player