Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing sound in HTML without installing a plugin

Tags:

html

jquery

php

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 the body.

Thank you.

like image 395
good_evening Avatar asked Jul 06 '11 21:07

good_evening


2 Answers

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>
like image 170
Michael Irigoyen Avatar answered Sep 21 '22 12:09

Michael Irigoyen


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."

like image 32
feeela Avatar answered Sep 23 '22 12:09

feeela