直接奉上示例代码,废话就不多说了。 复制代码代码如下: !doctype html html lang="en" head meta charset="UTF-8" title HTML Audio API /title link rel="stylesheet" href="./style/main.css" / script src="./script/audio-controls.js" /script /head body header h1 HTML5 Audio API /h1 p HTML5 Audio API demo by a href=" a href="http://github.com/LearnShare" http://github.com/LearnShare /a " target="_blank" LearnShare /a . /p p Last update @2013-04-23 20:40:00 + add info table update @2013-04-22 14:54:00 + add DOM events update @2013-04-22 12:47:00 + add getCurrentSrc button /p p View code on a href=" a href="http://github.com/LearnShare/LearnShare.github.io/tree/master/labs/audio/" http://github.com/LearnShare/LearnShare.github.io/tree/master/labs/audio/ /a " target="_blank" LearnShare.github.io /a . API reference: a href=" a href="https://developer.mozilla.org/zh-CN/docs/DOM/HTMLMediaElement" https://developer.mozilla.org/zh-CN/docs/DOM/HTMLMediaElement /a " target="_blank" HTMLMediaElement /a and a href=" a href="http://www.w3schools.com/tags/ref_av_dom.asp" http://www.w3schools.com/tags/ref_av_dom.asp /a " target="_blank" Audio/Video DOM References /a /p /header article section h2 Audio Element /h2 audio id="audio" src="./media/music1.mp3" controls="controls" /audio p Open the strong developer tool /strong to view console logs. /p /section section h2 Controls /h2 button id="play" play /button button id="pause" pause /button button id="get_paused" getPaused /button button id="get_ended" getEnded /button