davidohayon669 / react-native-youtube

A <YouTube/> component for React Native.
MIT License
1.16k stars 472 forks source link

java.lang.IllegalStateException This YouTubePlayer has been released #526

Open vqminh opened 3 years ago

vqminh commented 3 years ago

This happened around here

com.google.android.youtube.player.internal.s.play (s.java:2) com.inprogress.reactnativeyoutube.YouTubePlayerController$1.run (YouTubePlayerController.java:315) android.os.Handler.handleCallback (Handler.java:938)

The code to embed the player is:

<YouTube apiKey={ANDROID_API_KEY} videoId={videoId} // The YouTube video ID onError={reportError} play={true} modestbranding={true} rel={false} style={{alignSelf: 'stretch', height: 300}} />

vqminh commented 3 years ago

Maybe we should check if the player has been released then remount before calling play()?

public void onVideoFragmentResume() { if (isResumePlay() && mYouTubePlayer != null) { // For some reason calling mYouTubePlayer.play() right away is ineffective final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { mYouTubePlayer.play(); } }, 1); } }

neilakoh commented 2 years ago

any solution to this? keeps the app crashing