?
Solved

Sound errors

Posted on 1998-04-28
2
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…

719 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