I am using React Player npm install for React project. The video player is in a modal. How do I stop it from playing when the modal closes? Is there a ReactPlayer.stop()
or a ReactPlayer.pause()
type of functionality that I can add in my hideModal
function?
<Modal show={this.state.show} handleClose={this.hideModal} >
<ReactPlayer url='https://www.youtube.com/watch?v=ysz5S6PUM-U' width='100%'
height='100%' />
</Modal>
If this.state.show
returns Boolean value (true/false) you could control it through state like that:
<ReactPlayer url='https://www.youtube.com/watch?v=ysz5S6PUM-U' playing={this.state.show} width='100%' height='100%' />