Sound errors

I have written an internet page that plays a variety of sounds on the mouse over event. This works perfectly albeit I
have had to write different versions for different browsers. My problem which I noticed by chance when previewing the page on a machine without a sound card on the network. In at least netscape ver 3 (I think its ok in IE) the browser comes up with an error every time the mouse is moved over the images that the onMouseover event tries to play a sound with. The error is "unable to initialise midi device" or something along thos lines.

What I need to know is: Is there any kind of scripts that can either check a machine to see if it has a sound card so that i can load an alternative page. Or stop this particular error from being displayed taking in to account it is not a Javascript error as such and the window.onerror = noerror function does not work.

the code I am using to play the sound is:
function MM_controlSound(sndAction,sndObj) {
      if (eval(sndObj) != null) {
        if (sndAction == 'stop') eval(sndObj+'.stop()'); //stop, else play
        else
    eval(sndObj+((navigator.appName=='Netscape')?'.play(false)':'.run()'));
      }
    }

I am calling this function via:
<a href="about_boliden.htm"
    "javascript:changer()"
    onMouseOver="top1.src=fade1.src, MM_controlSound('play','document.controlS1')"
    onMouseOut="top1.src=reappear1.src, MM_controlSound('stop','document.controlS1')"><img
    src="aboutb1.JPG" border="0" WIDTH="157" HEIGHT="57"></a><img src="top4.JPG" NAME="top1"
    WIDTH="35" HEIGHT="57">

and am "declaring" the sound file with:
<embed name="controlS1" src="trump1.mid" loop="false" autostart="false"
mastersound="mastersound" hidden="true" width="0" height="0">

any help appreciated

Harry.
LVL 2
hboysAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Holger101497Connect With a Mentor Commented:
What you need to do is check if the audio-plugin is installed (if it is, you can play sounds (I guess even the absence of a sound card wouldn't cause an error-message -> programs don't care if there IS a sound card, Netscape probably complains because there's no audio-plugin on a machine without sound card).

I am not sure which plugin is responsible for the sound you're playing... here's a little choice for you (some of my plugins)
plugins["Netscape Default Plug-in"] = [object Plugin]
plugins["Netscape Media Player"] = [object Plugin]
plugins["Cosmo Player 2.0"] = [object Plugin]
plugins["LiveAudio"] = [object Plugin]
plugins["RealPlayer(tm) LiveConnect-Enabled Plug-In (32-bit) Version 5.0"] = [object Plugin]

To check if they are there, you can just do this:
if (navigator.plugins["LiveAudio"]) play sound; else do nothing; (I'm not sure which plugin is in charge...)

Oh, btw: (no guarantee given or tests made)
couldn't you simplify your function??

function MM_controlSound(sndAction,sndObj) {
  if (navigator.plugins["LiveAudio"])
    if (sndObj) {
            if (sndAction == 'stop') sndObj.stop(); //stop, else play
            else
        eval(sndObj+((navigator.appName=='Netscape')?'.play(false)':'.run()'));
          }
}

Good luck!
0
 
hboysAuthor Commented:
Holger,

Cheers! worked perfectly,

by the way it was the "Netscape Media Player" plugin that was causing the error to occur
when there was no sound card.

Thanks

Harry.
0
All Courses

From novice to tech pro — start learning today.