React-native-youtube: app crashed when place Youtube component inside a modal "Android"

Created on 5 Jun 2017  路  26Comments  路  Source: davidohayon669/react-native-youtube

The component renders fine on IOS but on Android it crashes without any errors !

"react": "16.0.0-alpha.6"
"react-native": "0.44.2"

help wanted

Most helpful comment

All 26 comments

Try logging the console https://facebook.github.io/react-native/docs/debugging.html#accessing-console-logs

I will push a fix for Android on RN > 0.44 the next days

@davidohayon669 do you have any updates? I am also facing the same problem. I am trying every possible way to run youtube on android but everything fails. Please do provide me a proper solution.

Thanks!

@davidohayon669 Has this been fixed yet?

@pallavisingh1511 I don't understand the problem

@davidohayon669
So, I've a button on the home screen. Upon clicking that button a modal appears and a video plays in that modal.
Now, this setup works perfectly fine on iOS.
But on Android, the app crashes whenever the modal opens.

react-native: 0.45.1

@pallavisingh1511 what home screen? what is a modal and how is it mounted and displayed?
provide more code

Guys I fixed that by using react-native-popup-dialog rather than react native built in modal

Hey @davidohayon669,
Following is the code.
Here, when the image is pressed, the modal opens and plays the video.
On iOS it works as expected, while on android the app crashed once the image is pressed.

` this._playVideo(!this.state.modalVisible)
}}>


animationType={"slide"}
transparent={true}
visible={this.props.visible}
onRequestClose={() => {this.props.playVideo(false)}}
>


ref={(component) => {
this._youTubeRef = component;
}}

        apiKey="apiKey"
        videoId={this.props.videoId}
        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={Platform.OS === 'ios'
        ? e => this.setState({ duration: e.duration, currentTime: e.currentTime })
        : undefined}
    />
</View>

`

Log for any error on onError, and log the device / emulator console with react-native log-android

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnnykoo84 picture johnnykoo84  路  4Comments

ishita-kothari picture ishita-kothari  路  5Comments

MattJLeach picture MattJLeach  路  5Comments

LorienHW picture LorienHW  路  3Comments

webdevbyjoss picture webdevbyjoss  路  4Comments