Open priyankagupta23pg opened 4 years ago
It happens in my case too. I noticed it happens with some of videos only. 90% of videos are pretty good. When I specify the same videoId from Xml attributes, it works fine, but I need to do it from code:
youtubePlayer.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
override fun onReady(youTubePlayer: YouTubePlayer) {
youTubePlayer.cueVideo(videoId, 0f)
}
})
@m-akopov can you please confirm that it happens only when playing programmatically? It seems very strange to me.
My understanding of this issue is that YouTube does not allow certain videos to be played on an embedded player.
@PierfrancescoSoffritti
Yes I confirm. From XML is fine. I tried everything, even set ReadyListener after 2000 milliseconds :D and then onReady cueVideo, or loadVideo. But without success.
Now I have
Can you send me a few ids of videos that have this problem?
Sure, here are videos:
I was having the same issue as @m-akopov but I think I found a way to solve it. Here's how I'm setting the videoID programmatically:
private fun setupVideo(vidId: String) {
val youtubePlayerView: YouTubePlayerView = binding.resourceVideo
lifecycle.addObserver(youtubePlayerView)
youtubePlayerView.enterFullScreen()
youtubePlayerView.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
override fun onReady(youTubePlayer: YouTubePlayer) {
youTubePlayer.loadVideo(vidId, 0f)
youTubePlayer.play()
}
})
}
On the XML side I removed the autoPlay
and videoId
properties.
In my case, this error was when I tried to use youtube links instead of video Id.
i solve this issue just removing autoplay and viodeo id from xml file
I am passing video id but still getting this error on playing video using this library. while using that video id video is playing in official youtube player. So need to remove this library from my project