react-native-youtube icon indicating copy to clipboard operation
react-native-youtube copied to clipboard

java.lang.IllegalStateException This YouTubePlayer has been released

Open vqminh opened this issue 4 years ago • 2 comments

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 avatar Aug 02 '21 17:08 vqminh

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); } }

vqminh avatar Aug 02 '21 17:08 vqminh

any solution to this? keeps the app crashing

neilakoh avatar Oct 19 '22 07:10 neilakoh