Answer the question
In order to leave comments, you need to log in
Why does video playback slow down if playback is controlled through html5-video events?
It is necessary to make "bookmarks" on the video - playing pieces of the video at a specified interval. This is convenient when there is a lecture (about 1 hour), and users sometimes need to watch or several techniques that take 5-10 minutes. Searching and scrolling for the user himself is also not very convenient.
<video id="video" tabindex="0" loop="loop" controls="controls" width="480" height="360">
<source src="day1.mp4" type="video/mp4;" />
</video>
<p><a id="fastFwd" onclick="skip(60, 68)">Отрезок 1</a></p>
<p><a id="fastFwd" onclick="skip(300, 308)">Отрезок 2</a></p>
function skip(value, endtimeoffset) {
var video = document.getElementById("video");
video.currentTime = value;
video.play();
video.addEventListener("timeupdate", function() {
if (video.currentTime >= endtimeoffset) {
video.pause();
}}, false);
Answer the question
In order to leave comments, you need to log in
It is better to put var video = document.getElementById("video");
it in a separate function that will only work when the video is loaded. You are parsing the DOM every time.
function skip(value) {
video.currentTime = value;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question