You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on adding in a commenting feature like soundcloud where the timestamp of the video is saved on the comment. However right now when I just use the elapsed time it starts the same counter. How can I get the timestamp?
The text was updated successfully, but these errors were encountered:
The current time of the video is output by the onProgress callback, and the duration is output by onDuration (unfortunately this has to be a callback because not all players instantly provide the duration of a video). To get what you want you could do something like:
classPlayerextendsComponent{state={duration: null,secondsElapsed: null}onDuration=(duration)=>{this.setState({ duration })}onProgress=(progress)=>{if(!this.state.duration){// Sadly we don't have the duration yet so we can't do anythingreturn}// progress.played is the fraction of the video that has been played// so multiply with duration to get number of seconds elapsedconstsecondsElapsed=progress.played*this.state.durationif(secondsElapsed!==this.state.secondsElapsed){this.setState({ secondsElapsed })}}render(){return(<ReactPlayerplayingurl='http://example.com/file.mp4'onDuration={this.onDuration}onProgress={this.onProgress}/>)}}
I am working on adding in a commenting feature like soundcloud where the timestamp of the video is saved on the comment. However right now when I just use the elapsed time it starts the same counter. How can I get the timestamp?
The text was updated successfully, but these errors were encountered: