开发者

Playing sound in HTML without installing a plugin

开发者 https://www.devze.com 2023-03-18 00:52 出处:网络
To play the sound I use this code: <embed src=\"sound.mp3\" hidden=\"true\" autostart=\"true\" loop=\"false\">. Example: http://www.w3schools.com/media/tryit.asp?filename=trymedia_soundmidiembed

To play the sound I use this code: <embed src="sound.mp3" hidden="true" autostart="true" loop="false">. Example: http://www.w3schools.com/media/tryit.asp?filename=trymedia_soundmidiembed

But Mozilla (just tried in Mozilla and it's enough why I want to find a solution) asks for the plugin (QuickTime). So, my question is, can I substitute my code to play the sound without asking people to download certain plugin? Or what should I do?

By the way, it is for live chat, when message arrives I add this code to t开发者_运维技巧he body.

Thank you.


I suggest looking into using HTML5's <audio> tag. Here's a good starting point: http://html5doctor.com/native-audio-in-the-browser/

Code example:

<audio src="media.mp3" controls preload="auto" autobuffer></audio>


Not a really good solution for today, but maybe tomorrow: jsmad "is a pure javascript MP3 decoder, based on libmad, with an ID3 decoder written from scratch.

For example, jsmad allows Firefox 4.0+ to play MP3s without any Flash. Faster loading times. Fewer security holes. No 64-bit headaches on Linux. Fewer memory leaks."


I don't think so, but there is an old IE-only html tag you can use:

<head>
 ⋮
 <bgsound src="sound.mp3"/>
</head>
0

精彩评论

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