代码示例:(标识:event_ontimeupdate_currenttime)
<!DOCTYPE html> 
<html> 
<body> 

<p>在本例中,我们将 "timeupdate" 事件附加到 video 元素。 currentTime 属性用于获取音频/视频播放的当前位置。</p>

<video id="myVideo" width="320" height="240" controls>
  <source src="/static/demo/video/shanghai.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video><br>

<button onclick="setCurTime()" type="button">将时间位置设置为 5 秒</button>

<p id="demo"></p>

<script>
// 获取 id="myVideo" 的 video 元素
var x = document.getElementById("myVideo");

// 将“timeupdate”事件附加到视频
x.addEventListener("timeupdate", getCurTime);

// 在 id="demo" 的 p 元素中显示视频的当前播放位置
function getCurTime() { 
  document.getElementById("demo").innerHTML = "The current playback position is " + x.currentTime + " seconds.";
} 

// 将当前播放位置设置为 5 秒
function setCurTime() { 
  x.currentTime = 5;
} 
</script> 

</body> 
</html>
运行结果: