Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillUnmount() {
const { casting } = this.state
GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_STARTED)
GoogleCast.EventEmitter.removeAllListeners(GoogleCast.SESSION_ENDED)
GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PLAYBACK_STARTED)
GoogleCast.EventEmitter.removeAllListeners(GoogleCast.MEDIA_PROGRESS_UPDATED)
if (casting) {
// Stop casting but keep the connection
GoogleCast.stop()
}
}
onActionSelected = position => {
switch (position) {
case 0:
GoogleCast.play()
break
case 1:
GoogleCast.pause()
break
case 2:
GoogleCast.stop()
break
case 3:
this.subtitlesEnabled = !this.subtitlesEnabled
GoogleCast.toggleSubtitles(this.subtitlesEnabled)
break
}
}