davidohayon669/react-native-youtube

java.lang.IllegalStateException This YouTubePlayer has been released

Opened this issue · 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}}
/>

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

any solution to this? keeps the app crashing