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

<p>在本例中,我们将 "ontimeupdate" 事件分配给 audio 元素。当用户开始播放视频或跳到音频中的新位置时,会触发一个函数,该函数将显示音频播放的当前位置(以秒计)。</p>

<audio controls ontimeupdate="myFunction(this)">
  <source src="/static/demo/video/horse.ogg" type="audio/ogg">
  <source src="/static/demo/video/horse.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

<p>播放位置:<span id="demo"></span></p>

<script>
function myFunction(event) {
  // currentTime 属性返回音频/视频播放的当前位置
  document.getElementById("demo").innerHTML = event.currentTime;
}
</script>

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