Jump to timestamp in a video that hasn't buffered yet

Viewed 12

I have a video on my page embedded with <video> and I'm using a list of timestampped key moments below the video for the user to click on and jump to that point in the video.

The first few timestamps work great, but if the user clicks on a timestamp that's in a section of the video that hasn't loaded yet, it jumps to the last frame and stops playing the video. Even once the video has fully loaded the later timestamps still don't work.

Here's the code i'm using:

let vid = jQuery("#topic-video")[0];
function skipTime(time) {
    vid.play();
    vid.pause();
    vid.currentTime = time;
    vid.play();
};

jQuery(".timestamp").click(function(){
    let timeStamp = jQuery(this).find('div').attr('data-stamp');
    let a = timeStamp.split(':');
    let totalSeconds = (a[0]*60)+(a[1]); //Convert MM:SS to all seconds
    skipTime(totalSeconds);
});

Is there a way for me to force load the entire video?

0 Answers
Related