开发者

javascript play sound too slow start

I'm using this to play sounds:

function playSound(soundfile) {
    document.getElementById("dummy").innerHTML = 
       "<embed src='"+soundfile+"' hidden='true' autostart='true' loop='false' />";
}

And it is sooo desperatly sloooowwwww to start!!!

My target is to play a short "chck" when the mouse hover a thumbnail, and when I have 10 thumbnails close to eachother, I want to hear: "chck-chck-chck...."

But not开发者_运维问答 "................../.................chck......../.......chck........./.........."

Admitedly the 1st time the sound file have to be loaded from the server, but after? It is STILL slow to start.

Of course, I would like a cross-browsers solution.

Thanks in advance...


Put your emebed tag on your page like any other element, then use JavaScript to play the sound.

<embed src="success.wav" autostart=false width=1 height=1 id="sound1" enablejavascript="true">

document.getElementById("sound1").play();

http://www.phon.ucl.ac.uk/home/mark/audio/play4.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜