JavaScript 参考手册
Audio currentTime 属性
将时间位置设置为 1 秒
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> </head> <body> <audio id="myAudio" controls> <source src="/examples/horse.ogg" type="audio/ogg"> <source src="/examples/horse.mp3" type="audio/mpeg"> 您的浏览器不支持 audio 元素。 </audio><br> <button onclick="getCurTime()" type="button">获取当前时间位置</button> <button onclick="setCurTime()" type="button">设置时间点为 1 秒 </button> <script> var x = document.getElementById("myAudio"); function getCurTime() { alert(x.currentTime); } function setCurTime() { x.currentTime = 1; } </script> </body> </html>
运行结果:
点击运行 »