Search code examples
androidandroid-youtube-api

YoutubePlayerView goes black when i scroll down inside recyclerView


I have a recyclerview that will show all videos from youtube. i'm using YoutubePlayerView to display it. The problem is everytime i scrolls down half screen the current video screen goes black and will not load anymore. The videos will load just fine if i don't scroll half screen

Anybody know about this behavior?


Solution

  • The YoutubePlayerView has to be fully visible, otherwise the video gets stopped. Since you are putting it in a recyclerview part of the YoutubePlayerView is not fully visible when scrolling and gets stopped.

    In the documentation it says: Also, it is not permitted to overlay the view with other views while a video is playing. On the documentation page. You are probably not overlaying the video, but you are obscuring certain parts of the video when scrolling.