[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Playing sound (*.au or *.wav) OnMouseOver

Posted on 1998-12-14
8
Medium Priority
?
386 Views
Last Modified: 2012-08-13
Below is the "beep.js" file I am using which works great, but only for Netscape and I would like to have it work for IE as well. I just don't know the syntax to figure which browser and what the playsound function is for IE, could someone help? Basically I have image maps with embedded URL's that play a sound and show something in the status bar when the mouse pointer goes over it. I would like to get it working for IE, it already works for Netscape.
Thanks for the help.
In HTML file:
<SCRIPT type="text/javascript" src="beep.js">
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

In Beep.js file:
<!--
function playSound(name) {
    if (navigator.appName== "Netscape" && parseInt(navigator.appVersion) >= 3 &&
        navigator.appVersion.indexOf("68k") == -1 && navigator.javaEnabled() &&
        document.embeds[name] != null && document.embeds[name].IsReady()) {
    document.embeds[name].play(false);
    }
}
onerror = null

// -->
0
Comment
Question by:netsurfer
[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
  • 5
  • 3
8 Comments
 
LVL 6

Accepted Solution

by:
PBall earned 40 total points
ID: 1275643
Take a look at the same question posted by someone in microsoft sitebuilder site.

http://www.microsoft.com/sitebuilder/magazine/webmen.asp#klickity

Basically they suggest putting an empty BGSOUND tag in the HEAD section

<BGSOUND id=objSound>

to play a sound just change the src property in javascript:

function playsound(sURL) {objSound.src = sURL;}

.onmouseover='playsound("/sounds/bang.wav")'
0
 

Author Comment

by:netsurfer
ID: 1275644
Pball,
       If I understand your answer correctly, I need to change my OnMouseOver to reflect playsnd() instead of playsound() so that would work for IE, but then Netscape would'nt work. I need to change my beep.js to reflect the difference between IE and Netscape play sound commands and then have it play the proper one. Maybe I didn't make myself clear, but the difference in IE and Netscape play sound commands usable in the OnMouseOver command is what is confusing me. If I set it for one, the other won't work and visa-versa. Is there a way to dynamically change the command dependent upon which browser the end user has?

Thanks,
NetSurfer
0
 

Author Comment

by:netsurfer
ID: 1275645
Here is the URL for my web based game that needs to be IE compatible for sounds, it already works for Netscape, I figured I'd give you this because it would make it easier to understand what I am trying to do.

Thanks,
NetSurfer
http://members.xoom.com/NetSurfer/course1.html
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Expert Comment

by:PBall
ID: 1275646
Yes, do browser detection routine at the beginning of the page.
<head>
<bgsound id=snd1>
<script>
IEPlus = False;

if (navigator.userAgent.indexOf("MSIE") != -1 &&
    navigator.userAgent.indexOf("Windows") != -1 &&
    navigator.appVersion.substring(0,1) > 3)
    IEPlus = True;

function playSound( name, sURL )
//name for Netscape
//sURL for IE
{
  if (IEPlus)
    snd1.src = sURL;
  else
  {
     if (navigator.appName== "Netscape" && 
         parseInt(navigator.appVersion) >= 3 &&
         navigator.appVersion.indexOf("68k") == -1 &&
         navigator.javaEnabled() &&
         document.embeds[name] != null &&
         document.embeds[name].IsReady())
       document.embeds[name].play(false);
  }
}
onerror = null;
</script>
<body>
<embed name=nsound1 src="blah.wav" ....>
<a href='...' onmouseover='playSound("nsound1","blah.wav")'>...</a>

0
 
LVL 6

Expert Comment

by:PBall
ID: 1275647
There was a reference point for LiveAudio that supposedly you can replace the current source w/ other file, but so far, I am unable to make it work on Netscape.

document.NSnd.play(false,url_here)  doesn't work for some reason.

something to do w/ a stub wav file or something like that.

0
 

Author Comment

by:netsurfer
ID: 1275648
Here is what I have done, I have a beep3.js file which contents are below.
My html file has the following in it and it seems to work fine for both IE and Netscape, but I cannot get my window.status to work in Netscape now.... It worked fine before, and works fine in IE, but I lost it somehow. I have tried using " instead of ' in the onMouseOver line, but it doesn't matter...Any ideas why?
HTML File
-------------
<HEAD>
<BGSOUND id=snd1>
</HEAD>
<SCRIPT type="text/javascript" src="beep3.js">
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
<BODY>
<embed src="beep2.au" hidden="true" align="baseline" border="0" width="0" height="0" name="beep1" loop="FALSE" autostart="FALSE" mastersound>
<a href="beach2.html" OnMouseOver="playSound('beep1','beep2.au');window.status='BEEP!'; return true">...by placing your mouse pointer over this text until you hear a "BEEP",....</a>
=====================
Beep3.js
-------------
<!--
    function playSound( name, sURL )
     {
       {
         if (navigator.appName== "Netscape" &&
            parseInt(navigator.appVersion) >= 3 &&
            navigator.appVersion.indexOf("68k") == -1 &&
            navigator.javaEnabled() &&
            document.embeds[name] != null &&
            document.embeds[name].IsReady())
            document.embeds[name].play(false);
         else
            IEPlus = "False";
         if (navigator.userAgent.indexOf("MSIE") != -1 && 
            navigator.userAgent.indexOf("Windows") != -1 && 
            navigator.appVersion.substring(0,1) > 3)
            IEPlus = "True";
            snd1.src = sURL;
       }
     }
onerror = null
// -->
0
 

Author Comment

by:netsurfer
ID: 1275649
Here is what I have done, I have a beep3.js file which contents are below.
My html file has the following in it and it seems to work fine for both IE and Netscape, but I cannot get my window.status to work in Netscape now.... It worked fine before, and works fine in IE, but I lost it somehow. I have tried using " instead of ' in the onMouseOver line, but it doesn't matter...Any ideas why?
HTML File
-------------
<HEAD>
<BGSOUND id=snd1>
</HEAD>
<SCRIPT type="text/javascript" src="beep3.js">
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
<BODY>
<embed src="beep2.au" hidden="true" align="baseline" border="0" width="0" height="0" name="beep1" loop="FALSE" autostart="FALSE" mastersound>
<a href="beach2.html" OnMouseOver="playSound('beep1','beep2.au');window.status='BEEP!'; return true">...by placing your mouse pointer over this text until you hear a "BEEP",....</a>
=====================
Beep3.js
-------------
<!--
    function playSound( name, sURL )
     {
       {
         if (navigator.appName== "Netscape" &&
            parseInt(navigator.appVersion) >= 3 &&
            navigator.appVersion.indexOf("68k") == -1 &&
            navigator.javaEnabled() &&
            document.embeds[name] != null &&
            document.embeds[name].IsReady())
            document.embeds[name].play(false);
         else
            IEPlus = "False";
         if (navigator.userAgent.indexOf("MSIE") != -1 && 
            navigator.userAgent.indexOf("Windows") != -1 && 
            navigator.appVersion.substring(0,1) > 3)
            IEPlus = "True";
            snd1.src = sURL;
       }
     }
onerror = null
// -->
0
 

Author Comment

by:netsurfer
ID: 1275650
i will put both test files out on my site if you want to look at them and see if I screwed something up. site address is http://members.xoom.com/NetSurfer/beach2.html
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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

650 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