IE4 sound playing

I have set up a web page that both changes an image and plays a sound on the onMouse over event! This is great in Netscape 3+4. for IE3 I have a seperate page with just an animated gif and background sound. The html page has a script that senses the browser type and loads the apprpriate page. my problem lies with IE4. This works fine with the images but has problems playing the sound. Javascript errors occur.

The problem probably is to do with the way I am declaring the sound files to play i.e. with the embed tag.

what can I do to get this working, preferably one page for netscpae & IE4.

The script I am using 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 declaring the sound file with:
<embed name="controlS1" src="trump1.mid" loop="false" autostart="false"
mastersound="mastersound" hidden="true" width="0" height="0">

and calling on the onMouseover event handler:
<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>

Another problem I am having occurs when there is no sound card in machine under netscape 3(at least, havent tested in others) every time I move mouse over graphic to play sound it gives an error saying unable to initialise midi etc. I can in at least in IE4 call window.onerror =
noerror which will get rid of this problem.

any help appreciated,

Harry.
LVL 2
hboysAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hboysAuthor Commented:
P.S any good Javascript books that you can recommend?which can be  got on the internet.

thanks

Harry.
0
Michel PlungjanIT ExpertCommented:
This seems to be the current solution:

Navigator:  <EMBED NAME="sound" SRC="noise.wav" HIDDEN="TRUE"
             AUTOSTART="FALSE" MASTERSOUND>

            document.embeds["sound"].play(LOOP=1);


Explorer:  <OBJECT ID="sound" WIDTH="0" HEIGHT="0"
            CLASSID="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A">
           <PARAM NAME="FileName" VALUE="noise.wav">
           <PARAM NAME="PlayCount" VALUE="1">
           <PARAM NAME="AutoStart" VALUE="0">
           <PARAM NAME="ShowControls" VALUE="0">
           <PARAM NAME="ShowDisplay" VALUE="0">
           </OBJECT>

           sound.Run();

Enjoy

The book I have enjoyed the most is Flanagan's JavaScript, The definitive Guide - http://www.ora.com

I get the rest of my script info from http://developer.netscape.com

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hboysAuthor Commented:
Thanks

Thats half the question answered but is there any way that I can either disable the "unable to initialise Midi" error or check via javascript if the computer has a sound card fitted so that I can load an alternative page?

Harry.
0
Michel PlungjanIT ExpertCommented:
There are several but they are not 100%

1.I cannot remember where the message is coming from (I have had sound cards since 1990) but if it is issued by javascript, you can do an
window.onerror = null;
in Netscape 3+ and MSIE 4.

2. Look through the navigator.plugins array to see if a player is available - only works in netscape and you will need to know which players are out there
This is assuming that the user will not have installed a midi player if he/she did not have a sound card.

3. Use a java applet, but that would be a question in another section.

If this is not enough, please reopen your second question

Michel
0
hboysAuthor Commented:
cheers Michel,

Good question answer in the first part so I'll give you all the points anyway.

Not sure wether its a plugin problem as its just trying to play a sound on a machine without a sound card. I'll open it as a seperate question.

Thanks

Harry.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.