【发布时间】:2013-07-02 17:59:02
【问题描述】:
我想创建一系列函数,用于存储单击时将播放的 mp3 文件。 例如。我想,比如说,点击#3播放某种声音或mp3,然后点击#5等,等等。
var a1_Events = [newsound1, newcoolersound2, coolestsound3],
a1_c = 0;
function newsound1(){
// I would like to trigger a mp3 here. But not loop.
}
function newcoolersound2(){
// I would like to trigger a mp3 here. But not loop.
}
function coolestsound3(){
// I would like to trigger a mp3 here. But not loop.
}
$('#area1').click(function(){
a1_Events[a1_c++ % a1_Events.length]();
});
更新:
好的,所以,我想我有一个解决方案;但它看起来有点笨重——希望有更好的东西;但我的实施计划是将以下内容嵌套在 div 中,并通过上面的功能区域中的 show / hide onClick 显示按钮。
//mp3 File 1
<audio id="id1" src="01.mp3"></audio>
<button onClick="document.getElementById("id1").play()">Play</button>
<button onClick="document.getElementById("id1").pause()">Stop</button>
【问题讨论】:
-
我认为应该可以。
标签: javascript jquery html audio