Saturday, April 8, 2006

Background Audio or Music Not Playing in Firefox Browser Problem

I'm posting this because this problem drove me crazy for a while.

Namely--

I wrote a webpage with embedded audio using bgsound; it played fine in IE but NOT in Firefox.

I searched high and low for a fix and most posts dealing with this issue were dealing with it from the point of view of the Firefox-user going to a page with embedded sound and not hearing it play.

This struck me as odd since if a page has embedded audio and you don't hear it play then how do you know that you've got a problem? Reminds me of the age old question-- If a tree falls in a deserted forest does it still make a sound?).

I mean if the problem was that it played badly-- stuttering or faint or something like that, then you would know you had a problem but if it doesn't play at all?

Well for those Firefox users who want to know with certainty that any page with embedded audio will play that audio file then the solution seems to require a Greasemonkey add-on found here GREASEMONKEY ADD-ON (also see this LINK ).


BUT, This post is for the webmastering side of the issue which is simply this:

IF YOU WANT ANY USER (both IE and Firefox users) TO BE ABLE TO HEAR YOUR EMBEDDED BACKGROUND SOUND THEN DO NOT USE bgsound (only) BUT CODE IT THIS WAY:

(NOTE: Replace the 2 occurrences of "your-file.mp3" in the below code snippet with the url of your actual file).

Here's your code ________________________________________________


<!-- START SOUND CODE, DELETE TO REMOVE -->
<script language="JavaScript" type="text/javascript">
if (navigator.appName == "Microsoft Internet Explorer") {
document.write('&ltbgsound src="your-file.mp3" LOOP="false">');
}
else {
document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" Name="MediaPlayer" src="your-file.mp3" AutoStart="true" ShowStatusBar="0" ShowControls="0" ShowDisplay="0" volume="1" HEIGHT="1" WIDTH="1" loop="false"><br>');
}
// End -->
</script>
<!-- END SOUND CODE -->


Did This Tip Help You? Maybe it added a year to your life?

If it did would you consider helping us out with a donation?





All the best,

Michael Rotolo
www.rotolomedia.com





No comments:

Post a Comment