我正在尝试在播放视频时获取寻道时间。我使用播放事件,它只触发视频开始。
HTML:
<video controls id="videoFile">
<source src="Why Linux over Windows 3D Animation.mp4" id="video_here">
</video>
Java 脚本:
var secondvideo = document.getElementById('videoFile');
secondvideo.addEventListener('play', function(e) {
// The video is playing
console.log("current time= "+ document.getElementById('videoFile').currentTime);
});
最佳答案
secondvideo.addEventListener("timeupdate",
function (ev) {
console.log(ev.target.currentTime);
});
https://www.w3.org/TR/html5/embedded-content-0.html#handler-mediacontroller-ontimeupdate
在这里您可以找到 HTML5 视频事件和 API:https://www.w3.org/2010/05/video/mediaevents.html
关于javascript - 如何在用javascript播放视频时获取搜索时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46296117/