Solved

Sound errors

Posted on 1998-04-28
2
249 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 50 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building JSON/JQuery Results Display 11 54
Angular2 remove duplicates 11 24
Updating checkbox via JQuery does not trigger Knockout binding 6 60
Json and ajax javascript 24 23
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 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)

734 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