<video id='vsingle' src='test.mp4' poster='poster.jpg' controls></video>
<p class='story' data-start=5>lorem ipsum</p>
<p class='story' data-start=10>dolor sit</p>
var vid = document.getElementById("vsingle");
$('.story').on('click', function(){
let x = $(this).attr('data-start');
vid.currentTime=x;
vid.play();
});
the above works fine - i.e. video starts from x
now I need to add endTime
- something like this:
<p class='story' data-start=5 data-end=10>lorem ipsum</p>
$('.story').on('click', function(){
let x = $(this).attr('data-start');
let y = $(this).attr('data-end');
vid.currentTime=x;
vid.endTime = y;
vid.play(); // from `x` to `y`
});
how to set the endTime
and play the video from x
to y
?