Solved

Sound errors

Posted on 1998-04-28
2
243 Views
Last Modified: 2013-11-18
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.
0
Comment
Question by:hboys
2 Comments
 
LVL 6

Accepted Solution

by:
Holger101497 earned 50 total points
Comment Utility
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
 
LVL 2

Author Comment

by:hboys
Comment Utility
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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now