Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sound errors

Posted on 1998-04-28
2
Medium Priority
?
256 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 150 total points
ID: 1273173
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
ID: 1273174
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

772 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