We help IT Professionals succeed at work.

Embed audio files in HTML and make it work cross-browsers

Hi guys,

We're having a hard time embedding an audio file in an HTML page (we are using ASP.NET 2.0, but the code is actually HTML).
The audio should play automatically only once and no controls should be shown.

Case is, we originally used the code below, which worked fine on IE 8, Firefox 8, Chrome 15, Safari 5, and Opera 11.5:

<embed src="../Audio/warning.mp3" hidden="true" autostart="true" loop="false" width="0" height="0" />

But, probably after an update of some sort (or the installation of some codecs or something like that), it stopped working on IE 8 and IE 9 at our client's office; however, it still works fine on our computers when running from our localhost. However, when running from our internet server, we already have issues on Firefox.

After some investigation on the web, we asked our client to uninstall QuickTime, but that didn't help.
Also, we tried other tags such as <object> and even <audio> (HTML 5), but those don't seem to work properly on all browsers.

I guess my question is, do you guys have any suggestion on how to embed audio files so that it would work fine on all browsers?

Thank you.

Daniel
Comment
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
The only way I have done that is with Flash.  It's the only thing I use Flash for.  Everything depends on the players installed in the users computer and Flash is the most common and reliable for this purpose.

Commented:

Or install Winamp with MP3, AAC, WAV and other plug-ins for IE and Firefox or VLC Media play with checked option Install VLC plug-ins for Firefox, during the installation.

www.videolan.org

It is evidently that every computer has or has not that plugins.

Look at this file that I sent to you. It works for me only under IE 8 ( for other versions og IE I don't know )

Nrisimha ie8.html

I am sorry, but I can't upload warning.mp3, because it is forbidden at this site.

With my best regards

Nrisimha

Commented:

Hi Daniel,

You will not believe, but your code can work under IE and Firefox.

Do you know what was a problem with my Firefox?
You wrote a code:

<embed src="warning.mp3" hidden="true" autostart="true" loop="false" width="0" height="0" />l

I was spent a 4 hours to solve this problem under Firefox. And you know what?
The problem was solved when I change a WIDTH to be 1 instead of 0 and HEIGHT to be a 1 instead of 0 and remove command hidden="true" !!!

Incredible !

And my new code is:

<embed src="warning.mp3" autostart="true" loop="false" width="1" height="1" />

I also give to you a HTML file and warning.mp3 so you can test that:

http://ul.to/uzray3u7


good night and good luck

Nrisimha