How to get and set the value of the playhead/timeline with JavaScript

Jul 21, 2023

I'm trying to make my videos more interactive by utilising the HTML5 DOM.  The problem is that the time of the media easily goes out of sync with the timeline.

For example, if you insert a cue on the playhead at 1 minute to show a caption, and the user pauses, skips ahead or rewinds the video using controls which access the HTML5 DOM (e.g. video.pause() ), the media and the timeline will become out of sync and the caption will appear in the wrong place.

I'd like to be able to keep the media and timeline in sync by setting the value of the playhead/timeline to be the same as the media (video).  Is this possible?

 

Be the first to reply