Need help getting an embedded mp3 to play in both Firefox and IE

I have a website with an embedded mp3.

I first used the following code:

<embed src="ft.mp3" autostart="true" loop="true" hidden="true" type="audio/mpeg">

The above seemed to work in both IE and Firefox until I got on my computer at work which doesn’t have the Apple Quicktime plugin for Firefox. Isn’t Firefox smart enough to realize that I still have Windows Media Player available to play it with?

Anyways, I tried this next:

<embed TYPE="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" SRC="ft.mp3" Name="MediaPlayer" loop="true" ShowControls="0" autostart="true"></embed>

This made it play in both Firefox and IE, but for some reason on my win2k box IE plays the mp3 in Apple Quicktime and the player isn’t hidden!

How the heck do I get an embedded mp3 to play in both IE and Firefox with whatever freaking media player the user has? Yes, I read the FAQs about Firefox, and nothing helped.

Duplicate thread removed - please do not cross-post.

Well why did you remove the one in Multimedia, since this thread makes more sense there? If you’re going to remove duplicate threads at least remove the one that doesn’t belong.

Your best solution in this instance would probably be to use Flash to embed the mp3 as it has a much higher user penetration than either quicktime or wmp.

You can embed it so that the user isn’t even aware the flash is there visually, but having music play on a website with no option to turn it off is a sure way to drive visitors away from your site.

I am moving this thread to multimedia for you, but as it seems you’re aware that it doesn’t belong here, please be a little more corteous in future.

Here’s the solution. I got this from the creator of the Greasemonkey Scripts (scripts that help you embed media that works in both Firefox and IE).

Short answer - use this code instead:

<embed src="ft.mp3" type="application/x-mplayer2" autostart="true" playcount="true" loop="true" height="0" width="0">

Explanation (if you’re interested):
“Isn’t Firefox smart enough to realize that I still have Windows Media Player available to play it with?”
That’s not how it works. IE uses Windows Media Player itself to play any media file that WMP recognises. All other browsers must use the 7-year-old WMP plugin. Browser plugins have a list inside them of the file extensions and MIME Types they can play. A browser is supposed to use these lists to choose a plugin to play a file. The WMP plugin only lists the Windows Media formats: .asf, .asx, .wm, .wma, .wax, .wmv, and .wvx
Since Firefox obeys those lists (as it should), it will not use the WMP plugin to play an mp3, because the WMP plugin does not list mp3’s.

Adding TYPE=“application/x-mplayer2” was the correct solution - application/x-mplayer2 is a MIME Type that the WMP plugin lists (MIME Types are file identifiers used on the internet), and the type attribute overrides the actual file extension and MIME type of the file to be played.
Unfortunately, IE ignores MIME Types and file extensions - instead it examines the contents of the file and decides for itself what format it is and what to do with it. It plays with Quicktime on your win2k box because its browser plugin must list mp3 files. IE will use WMP to play a media file unless another browser plugin lists it.

Also, the WMP plugin does not support all the same parameters as the WMP ActiveX control (what IE uses) and the Quicktime plugin. For example, Quicktime does not support the ‘showControls’ parameter - which is WMP only (since for the WMP plugin the controls are only a part of the UI, not all of it)
And the WMP plugin does not support the hidden parameter properly - it prevents it from autostarting.
The best way to hide a player that will work for all media player plugins is to set the width and height to 0
The WMP plugin also doesn’t support the loop parameter - it needs playcount instead.

Use this code instead:

<embed src="ft.mp3" type="application/x-mplayer2" autostart="true" playcount="true" loop="true" height="0" width="0">

It will work in all browsers - autostart, hidden, and loop to infinity (that’s what you wanted, right?) and in all Windows browsers bar IE it will play with the WMP plugin. IE will use whatever browser plugin is associated with mp3’s, else it will use WMP.

I used the following code:

</style>
<object data="sign-of-the-cross-j09.wav" type="application/x-mplayer2" width="0" height="0">
<param name="filename" value="sign-of-the-cross-j09.wav">
<param name="playcount" value="true">
<param name="autostart" value="true">
</object>
<script language="JavaScript">

Background sounds works in both Firefox & IE, however, Firefox has a short pause at the end of loop that is really annoying. Is there any solution to make the loop more seamless in Firefox?