8
我想在HTML5中设置视频的时间位置。时间应该设置这样的:为什么在Chrome中设置HTML5视频元素重置时间的currentTime?
function settime(){
var video = document.getElementById("video");
console.log(video.currentTime); //----->output for example 15.3
video.currentTime = 10.0;
console.log(video.currentTime);//----->>output always 0
}
而且嵌入视频这样的:
<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>
但由于某些原因,这始终只是在Chrome重置currentTime的为0。
为什么在设置currentTime时重置时间?我怎样才能正确设置currentTime?
是视频本身,在视觉上,也将回到开始还是只是显示0的console.log? – K3N
是的,任何想法为什么和我在做什么错了? – user2212461
片段对我来说似乎是正确的 - 设置currentTime也是异步的,但在这里应该不重要(因为视频以可视方式重置)。问题可能与此处未显示的其他部分有关。您是否有可能设置可重现此问题的小提琴/内联片段? – K3N