Solved

Sound on onmouseover click

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now