Solved

Sound on onmouseover click

Posted on 1998-11-09
2
164 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now