PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.46k stars 765 forks source link

I am getting a message like this: "An error occurred. Please try again later.(Playback ID: W.....cC)" #549

Open priyankagupta23pg opened 4 years ago

priyankagupta23pg commented 4 years ago

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

m-akopov commented 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)

            }
        })
PierfrancescoSoffritti commented 4 years ago

@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.

m-akopov commented 4 years ago

@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 and embedded video in iFrame with HTML and the same problematic videos(and all others) work fine.

PierfrancescoSoffritti commented 4 years ago

Can you send me a few ids of videos that have this problem?

m-akopov commented 4 years ago

Sure, here are videos:

https://youtu.be/Dzbb0OWnl2A https://youtu.be/X1Jqv1bESS8

aalloul commented 4 years ago

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.

vooda-- commented 4 years ago

In my case, this error was when I tried to use youtube links instead of video Id.

arti-pandey commented 4 years ago

i solve this issue just removing autoplay and viodeo id from xml file