Need help with sound mouse over

  • 1
  • Question
  • Updated 10 years ago
  • Answered
trying to get sound mouse over to work. Having no luck. Any suggestions?

testpager.yolasite.com/
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
  • confused

Posted 10 years ago

  • 1
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
It looks like you may not put your code in properly as part of the code is showing up on your site.

also.. you didn't put in your full path to your audio clip.

If you can post your code here, then we can help you out. Be sure to encode your code first. Go here: http://forsite.synthasite.com/encoder...
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
<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] = "http://testpager.yolasite.com/resourc... Shot.wav "; // DO NOT edit below this line document.write('<BGSOUND ID="auIEContainer">') 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> <!-- //onMouseOver/onMouseOut sound: --> <a href="http://testpager.yolasite.com/resourc...; onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A> <!--//Edit the aySound array to preload the sound files. //aySound[0]="resources/Gun Shot.wav"; //aySound[1]="AnotherSoundFile.wav"; //aySound[2]="EvenAnotherOne.wav"; -->
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Hi Harry

Just wanted you to know that I haven't forgot about you. It's been a very busy day today and I haven't had a chance to sit down at the computer and look at this in more detail. I'm hoping to get to it tomorrow.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Hi Harry.. I'm taking a look now at your code.

Can you please give me the location of where your audio files are held? Thanks.
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
is this what you mean?
"resources/Sounds/Gun Shot.wav 66451.wav" (that is what it shows when I put my mouse over the file in File manager
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
is this what you mean?
"resources/Sounds/Gun Shot.wav 66451.wav" (that is what it shows when I put my mouse over the file in File manager
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
yep.. that's what I'm looking for! Thanks. I'll get back to you. Thanks for being so patient with this.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
also.. could you please provide the url where you got your code please. I always like working from the original source in case there was a mistake in copying the code.
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Thanks for that source... but what I meant was.. where did you get your script code from?
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
It's okay Harry.. I found the source. I think the problem is this... on the site, it says the following: "the LiveAudio plugin must exist" in order for the sound to come through. This only seems to work with IE or NS - not Firefox.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Here's the code again.. I was able to make it work for me. Also.. looking at your audio file - it looks strange - I don't believe it should have two .wav in it.

Step 1: Copy & paste into an HTML box

<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] = "resources/gunshot sound fx 98010.WAV";

// DO NOT edit below this line
document.write('<BGSOUND ID="auIEContainer">')
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>

Step 2: Copy and paste into another HTML box
<A HREF="http://testpager.yolasite.com&quot; onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A>

Also... try downloading your audio file again.

Let me know if you need further help. In the meantime, I'll scrounge around and see if I can come up with an audio player that will work on all browsers.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Hi Harry

I found one that appears to play in both FF and IE.

Step 1: Copy & paste into an HTML box

<script type="text/javascript">
if (window.attachEvent)
window.attachEvent("onload", setupPlaySound);
else
window.addEventListener("load", setupPlaySound, false);

function setupPlaySound()
{
if (navigator.appName == "Microsoft Internet Explorer")
{
var snd = document.createElement("bgsound");
document.getElementsByTagName("body")[0].appendChild(snd);

playSound = function(url)
{

snd.src = url;
}
}
else
{
playSound = function(url)
{
var obj = document.createElement("object");
obj.width="0px";
obj.height="0px";
obj.type = "audio/x-wav";
obj.data = url;

var body = document.getElementsByTagName("body")[0];
body.appendChild(obj);
}
}
}
</script>

Step 2: Copy & paste into another HTML box. This is where you put in your audio file path.

<a href="SomePage.htm" onmouseover="playSound('resources/gunshot sound fx 98010.WAV')">Click Here!</a>

I hope this one does the trick for you. =)

If you want to see the testpage I created: http://littleustestsite.yolasite.com/...
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
littleus,
i am confused with step 2. The href=somepage.htm. i would like to have sound when a picture or a nav button is selected. Is that possible? i have tried to sub some page with pic to no avail. Plus I really appreciate the help you have given me
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Try this Harry:

<a href="YOUR PAGE URL" onmouseover="playSound('resources/gunshot sound fx 98010.WAV')"><img src="YOUR IMAGE PATH" border="0"></a>

The a href tag is to create a link, so when the person clicks on the text or image, they are taken to that page. If you don't want a link, then replace the link with #. Try implementing your image path inside the img src.

Let me know how it goes.
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
littleus, here is my link to my test page http://testpager.yolasite.com/. i cant get it to work.
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
Thats what i want. i added "...but it still doesn't work for me. my problem (confusion) is back to - some page (YOUR PAGE URL). I put http://testpager.yolasite.com/ and http://testpager.yolasite.com/index.p... place of above,
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
You're missing the = between href and "

It should look like this:

<a href="http://testpager.yolasite.com&quot; onmouseover="playSound('resources/gunshot sound fx 98010.WAV')"><img src="http://testpager.yolasite.com/resourc...; border="0"</a>
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
Here is what i have:
. I noticed your url on your page has /somepage.htm. When i put mouse on pic in my site it says http://testpager.yolasite.com and when the mouse is off the pic the status bar says "stopped"
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
whoops. <!--<a href="http://testpager.yolasite.com" onmouseover="playSound('resources/gunshot sound fx 98010.WAV')"> <img src="http://testpager.yolasite.com/resourc..." border="0"></a>-->
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
It all looks good to me.

You're still not able to go to your link page?
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
does it work for you if you go to my test page?
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
your page works, mine doesn't
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Your link now works.. but your sound doesn't. did you put the code in the proper order? 1st box should be the script code, 2nd box goes below and that should be the a href code.

Also.. what browser are you using?
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
FF
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Okay... so am I. It's very strange.

If you can persevere, I'm sure we can get this figured out.

I'm going to post the code again. Maybe I missed something? Your sound file should be in your resources folder right? It not in another folder as well as the resources folder?
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
Ok here goes. There is a file on my hard drive and one in resource folder. When i right click on the one in the res folder, i have to download it. the one in the res folder is the double .wav
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
if i right click on the res folder file, i have the option of-copy,rename,download and delete
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
yep.. that 's right.. so click on rename and give it a new name.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Harry.. check out my test site page.. is that what you're wanting to accomplish?
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
I think you're missing an " after your image file name. Try inserting that between .JPG and border="0"
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Okay.. try naming the audio file in your resources folder. It should read: gunshot sound fx 98010.WAV

Let me know when you've got that done.
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
That worked but the sound doesn't sound like your page plus it cut off.
http://testpager.yolasite.com/. try it now. and see if its me
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
It sounds good to me! I don't hear anything being cut off at all. Maybe you could repost your testpage in a new thread and see if others are experiencing the problem you're having when they visit it?
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
That worked but the sounds are different between your site and mine because there are two different gun shot sounds. I changed sounds. see iy it works for you. http://testpager.yolasite.com/
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
Yep.. it worked! =) Yay!!!!
Photo of Harry

Harry

  • 82 Posts
  • 0 Reply Likes
Thanks again. i don't know where you live but in your are ever in the philly area, you know how to get me, i'll buy your a beer.
Photo of Sanja

Sanja

  • 10698 Posts
  • 495 Reply Likes
You're very welcome! I'm so glad we got it to work. Thank you for being patient and not giving up! =)

As always, feel free to ask question if the need should arise.