I want to set the time position of a video in HTML5. The time should be set like this:
function settime(){
var video = document.getElementById("video1");
console.log(video.currentTime); //----->output for example 15.3
video.currentTime = 10.0;
console.log(video.currentTime);//----->>output always 0
}
And the video is embedded like this:
<button onclick="settime();">Set Time</button>
<div class="container">
<video id="video1" class="video-js vjs-default-skin" muted>
<source src="video.m4v" type="video/mp4" />
HTML5 Video is required for this example.
</video>
But for some reason, this always just resets currentTime to 0 in Chrome.
Why gets the time reset when setting currentTime? And how can I set currentTime correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…