davidohayon669 / react-native-youtube

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

Youtube player crashes when user clicks on notification when video is playing #432

Open cw-shubham-rajput opened 4 years ago

cw-shubham-rajput commented 4 years ago

crash logs Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference at com.google.android.youtube.player.YouTubeStandalonePlayer.getReturnedInitializationResult(Unknown Source:0) at com.inprogress.reactnativeyoutube.YouTubeStandaloneModule$1.onActivityResult(YouTubeStandaloneModule.java:44) at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:277)

Adding null check would help

diennt90 commented 4 years ago

I need play video youtube in my react native app and my app has crash same this problem My video

Share My code: <YouTube ref={this._youTubeRef} apiKey="ApiKEY" videoId={zQadr3b_kmo} play={this.state.isPlaying} loop={this.state.isLooping} fullscreen={this.state.fullscreen} controls={1} style={styles.player} onError={e => { this.setState({ error: e.error }); }} onReady={e => { this.setState({ isReady: true }); }} onChangeState={e => { this.setState({ status: e.state }); }} onChangeQuality={e => { this.setState({ quality: e.quality }); }} onChangeFullscreen={e => { this.setState({ fullscreen: e.isFullscreen }); }} onProgress={e => { this.setState({ currentTime: e.currentTime }); }} /> Please help me, thanks guys

davidohayon669 commented 4 years ago

@cw-shubham-rajput what notifications?

cw-shubham-rajput commented 4 years ago

@davidohayon669 push notifications.

jespejoh commented 4 years ago

I'm experiencing the same issue but when putting the app in the background while the video plays full screen – and it's pretty easy to solve (done in this PR actually --> https://github.com/davidohayon669/react-native-youtube/pull/368). It looks like the library cannot handle the switch from background to foreground. For now I'm solving it by patching the library locally (without any other known unintended consequences so far). It would be great if the fix is merged into the main repo :) Thanks for your work on this!

deepak-jha-kgp commented 4 years ago

I too have been using it for a while now with the patch in production for almost a month now. No side effects so far, looking forward to getting it merged.

zchwyng commented 4 years ago

+1

felansu commented 3 years ago

+1

akashshukla232582 commented 2 years ago

We are also facing same issues , please provide me solution on this

zabojad commented 1 year ago

Still happening on latest version:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference
    at com.google.android.youtube.player.YouTubeStandalonePlayer.getReturnedInitializationResult
    at com.inprogress.reactnativeyoutube.YouTubeStandaloneModule$1.onActivityResult(YouTubeStandaloneModule.java:44)