PDA

View Full Version : Sound mouseover


Troutman
10-18-2000, 03:20 PM
Hello,

I am having a hard time getting the audio plug-in to 'hide' when Netscape is playing a .wav file on a mouseover. The 'EMBED' code does not seem to work. Thanks for any help you can provide! Troutman
[code below]

<script language="Javascript">
MouseOverImage = new Image();
MouseOutImage = new Image();
MouseOverImage.src = "image1.jpg";
MouseOutImage.src = "image2.jpg";

function myMouseOver()
{
document.location.href ='transporter.wav';

if(document.images) {document.myImage.src = MouseOverImage.src;}
}


function myMouseOut()
{
if(document.images) {document.myImage.src = MouseOutImage.src;}
}

</script>

<A HREF = " " onMouseOver = "myMouseOver()" onMouseOut = "myMouseOut()">
<img name = "myImage" src = "image2.jpg">

<EMBED SRC="transporter.wav" loop="false" autostart="false"
mastersound="mastersound" hidden="true" volume="100" WIDTH="0"
HEIGHT="0" ALIGN="BOTTOM"></EMBED>

</A>

Ian
10-19-2000, 03:33 AM
Hi,
MouseOver Sound scripts that are cross browser compatable was an issue amoung script writers for a long time, normally they have supported one or the other, but not both, there was one written a while back by a talented guy who was able to get this to work, the script is featured on our very own A1 JavaScripts ( you can find it in the page effects category ) I have also included the script below, it only works in 4+ browsers and up, but I'm sure you can get some ideas from it.


<BGSOUND ID="auIEContainer">
<SCRIPT LANGUAGE="JavaScript"><!--
// Preload and play audio files with event handler (MouseOver sound)
// designed by JavaScript Archive, (c)1999
// Get more free javascripts at http://jsarchive.8m.com

var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "Chimes.wav";
aySound[1] = "Ding.wav";
// DO NOT edit below this line

IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE| |NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//--></SCRIPT>

<A HREF="YourPage.html" onMouseOver="playSound(0)"
onMouseOut="stopSound(0)"></A>


I hope this is of some value to you. Good luck.

------------------
Ian

Web Development - BIG Resources Inc
Head Guide - 123Webmaster.com (http://www.123webmaster.com/)
ian@123webmaster.com
BIG Resources.com (http://www.bigresources.com)
ICQ: 25828668