PierfrancescoSoffritti / android-youtube-player

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

An error occured. Please try again later #1147

Open mfrizki1 opened 5 months ago

mfrizki1 commented 5 months ago

I have a problem when play the video. version: 12.1.0

Case : when first time open the app, the video will start normally in fragment, but after go to another activity/fragment and come back to the fragment video player the video cannot to play. The message is An error occured. Please try again later. After i kill the app, the video start normally again.

mfrizki1 commented 5 months ago

When i override fun onError(youTubePlayer: YouTubePlayer,error: PlayerConstants.PlayerError). error : INVALID_PARAMETER_IN_REQUEST

PierfrancescoSoffritti commented 5 months ago

Please provide a code sample, or try to replicate in the sample app.

mfrizki1 commented 5 months ago

My code just like this

in fragment: image when first time open the fragment, video start normally

but after go to another activity/fragment, it goes to onError method with error : INVALID_PARAMETER_IN_REQUEST

image

PierfrancescoSoffritti commented 5 months ago

Can you double check that the video ID you're providing the second time is correct?

MahmoudMabrok commented 5 months ago

@mfrizki1 you can also try to use fixed id, and check if issue occurs or not.

if occurs, might data been lost between transition

FFMCloser commented 1 month ago

Good morning, maybe you have already solved it, but for anyone else who came here, we have face with the same situation and the problem was that the player don't initialize on time when we do the code as you (let the initialization be done automatically and only add an AbstractYouTubePlayerListener in order to know when the player is ready).

To solve the problem, we have:

This solves the problem for us.