Solved

Sound on onmouseover click

Posted on 1998-11-09
2
173 Views
Last Modified: 2008-03-10
I am wandering if s it possible to get sound with JS onmouse over click? Also, any possibility for SOUND PRELOAD?

regs
abusrbin
0
Comment
Question by:abusrbin
[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
2 Comments
 
LVL 10

Accepted Solution

by:
kollegov earned 100 total points
ID: 1273809
I have example on my page
at
http://www.geocities.com/siliconvalley/lakes/8620/soundlink.html

Here it is:
<HTML>
<HEAD>
<script>
 browserOK=false;
 laOK=false;
 midOK=false;
 wavOK=false;
 var loaded=false;
 
 
 filenames= new Array();
 filenames[0] = "passport.mid"
 filenames[1] = "chimes.wav"
 // pre-cache sounds as images.
 im0=new Image();
 im1=new Image();
 im0.src=filenames[0];
 im1.src=filenames[1];

 if(navigator.plugins["LiveAudio"])
    {browserOK=true; laOK=true;
     for(i=0;i<navigator.mimeTypes.length;i++)
       {mime=navigator.mimeTypes[i];

        // check LiveAudio enabled for WAV if you use wav
        if(mime.suffixes.indexOf("wav")!=-1)
          {if(mime.enabledPlugin==navigator.plugins["LiveAudio"])
             {wavOK=true;}
          }

        // check LiveAudio enabled for MIDI if you use midi
        if(mime.suffixes.indexOf("mid")!=-1)
          {if(mime.enabledPlugin==navigator.plugins["LiveAudio"])
             {midOK=true;}
          }
       
        // mask broserOK with midOK and wavOK
        // in case you use only 'midi', remove '&& wavOK'
        // and vice versa...
        browserOK=browserOK && midOK && wavOK;
       }    
    }
 if(navigator.javaEnabled()==false) browserOK=false;

 function playIt(n)  
 {p=canuse(n);
  if(p!=null)
   {if(p.IsReady())
     {if(p.IsPlaying()!=true)
        {p.play(false);}
     }
   }
 }

 function stopIt(n)
  {p=canuse(n);
   if(p!=null) {p.stop();}
  }
 
 function canuse(n)
  {if(browserOK==true)
     {if(eval("im"+n+".complete")==true)
       {if(loaded)
         {p=document.embeds["myplayer"+n];
          if(p.IsReady()) {return p;}
         }
       }
     }
   return null;
  }
</SCRIPT>

</HEAD>
<BODY TEXT="#00FF00" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF00FF" ALINK="#FF0000"> onLoad="loaded=true";

<EMBED src="passport.mid"
        hidden=true
        name="myplayer0"        
        autostart=false
        MASTERSOUND>

<EMBED src="chimes.wav"
        hidden=true
        name="myplayer1"        
        autostart=false
        MASTERSOUND>

<P>
<A HREF="index1.html"
 onMouseOut="stopIt(0)"
 onMouseOver="playIt(0)"
>Try this link for .mid</A>
</P>

<P>
<A HREF="index.html"
 onMouseOut="stopIt(1)"
 onMouseOver="playIt(1)"
>Try this link for .wav</A>
</P>

</BODY>
</HTML>
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1273810
I just forgot to mention that you need to have
"passport.mid" and "chimes.wav"
(files used to inialize EMBEDs) files in the same directory.
If your emebds refers to unexisting files initially
script wouldn't work :)

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

728 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