April 2020
Intermediate to advanced
716 pages
18h 55m
English
The MediaPlayer component receives the handleAutoplay method as a prop from PlayMedia. This method will be utilized when the current video finishes playing in the player. Hence, we will update the listener code for the onEnded event to execute this method only when the loop is set to false for the current video. We don't want to play the next video if the user has decided to loop the current video. The onEnded method in MediaPlayer will be updated with the highlighted code shown in the following block:
mern-mediastream/client/media/MediaPlayer.js
const onEnded = () => { if(loop){ setPlaying(true) } else{ props.handleAutoplay(()=>{ setValues({...values, ended: true}) setPlaying(false)Read now
Unlock full access