TinyPortal

Development => Feedback => Topic started by: whoesa on May 14, 2006, 11:08:35 AM

Title: Add wave sound to a button?
Post by: whoesa on May 14, 2006, 11:08:35 AM
Hi all,

I don't seem the find any information about this, so sorry if this has been asked before.

Is it possible to add a little wave sound to the Home,Forum,Search,etc buttons?
I have a nice sound that complitely matches our site but i have no idea if this can be done or where to start doing this.

Anyone has an idea?

Thanks in advance.
Title: Re: Add wave sound to a button?
Post by: G6Cad on May 14, 2006, 11:24:11 AM
I think you might get answers on SMF for this question if you post it there to :) The buttons in the top comes with SMF softaware and not TinyPortal :)
Title: Re: Add wave sound to a button?
Post by: Arba on May 14, 2006, 01:05:16 PM
Excelent idea,if you find a solution for that please post update in this thread  :)
I have board about reef aquarium and marine life,that option will be perfect for my board  8)
Title: Re: Add wave sound to a button?
Post by: bloc on May 14, 2006, 09:43:36 PM
Is it when hovering over buttons you need sounds? Or just a different repeating/non-repeating for each main section of the forum? - assumed when entering them.
Title: Re: Add wave sound to a button?
Post by: whoesa on May 14, 2006, 10:23:36 PM
What i would like to have is when i click on 1 of the buttons it makes that sound.

If i go over a button now, the button lights up and that is just fine. But when you click for example on Forum or Chat, at the exact same moment you should hear that wave sound.

Can this be done?
Sorry if my english is bad, i hope you understand what i mean  :)
Title: Re: Add wave sound to a button?
Post by: Crystallas on May 15, 2006, 07:43:24 AM
open index.template.php

add this line before the <?php  so you can keep your code orginized.


<script language="JavaScript">
function playSound()
{
if (document.all)
{
document.all.SoundExample.src = "http://www.wherever.com/path/file.wav";
}
</script>
<bgsound id="sound">


Then you locate the image you want to play this sound. Its not going to look exactly like this, but it should get you the idea of what to change.


<img
src="http://domain.com/Themes/Path/images/buttons/bar/button.gif"
border="0" width="X" height="X" onMouseover="playExampleSound()" onMouseOut=stopExampleSound">


onMouseover="playExampleSound()" onMouseOut="stopExampleSound()" Is what makes the sound work.

or substitute with
onClick="playExampleSound()"  to make it work when user clicks on the button :)

You might have to play with it to work the way you want, so make sure you backup the index.template.


Title: Re: Add wave sound to a button?
Post by: Crystallas on May 15, 2006, 08:04:55 AM
well.. i tried to help. It doesnt work as well as it did in my head. Maybe someone has a better idea.
Title: Re: Add wave sound to a button?
Post by: bloc on May 15, 2006, 10:04:50 AM
If Flash buttons were used, it would be a breeze.. ;) , but its possible in html/javascript too, at least in IE. Have a look at this link:

http://www.dynamicdrive.com/dynamicindex11/javascriptsound.htm

Is that something you could use?
Title: Re: Add wave sound to a button?
Post by: Nokonium on May 15, 2006, 08:08:23 PM
Sorry I couldn't resist the temptation - Sound on mouseover a block image  :2funny:

http://www.tinyportal.net/smf/index.php?topic=5153.msg41937#msg%msg_id%
Title: Re: Add wave sound to a button?
Post by: whoesa on May 17, 2006, 02:55:53 AM
Hi guys,

Yes that is what i could use, if it works  :)
I tried the code you gave me but i get an parse error or the sound is not working. Maybe it's me who does everything wrong  :uglystupid2:
I added the code in index.template.php of default theme, somewhere in the <HEAD> section as told. I only changed onMouseover with onClick because that is what i want to have.

Am i doing something wrong?


Title: Re: Add wave sound to a button?
Post by: bloc on May 17, 2006, 09:23:10 AM
Did you get the paths correct? Not having looked into it, that is many times the cause of trouble.
Title: Re: Add wave sound to a button?
Post by: whoesa on May 18, 2006, 02:41:02 AM
Yes that could be the problem i have  :)

In fact im not 100% sure how exactle the code and the paths should look like. I only tried the code i found on that site and that didn't work or i edited wrong. (i think it will be that last  ;D)

Would it be possible to post an example of the code and the paths?

Thank you in advance.

Title: Re: Add wave sound to a button?
Post by: G6Cad on May 18, 2006, 06:33:48 AM
Post it here and let some code master look at it :)
Title: Re: Add wave sound to a button?
Post by: whoesa on May 18, 2006, 07:29:56 AM
lol ok, this is for the code master  ;D

<bgsound src="#" id="soundeffect" loop=1 autostart="true" />

<script type="text/javascript">

/***********************************************
* JavaScript Sound effect- ÂÃ,© Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var soundfile="sidebar.wav" //path to sound file, or pass in filename directly into playsound()

function playsound(soundfile){
if (document.all && document.getElementById){
document.getElementById("soundeffect").src="" //reset first in case of problems
document.getElementById("soundeffect").src=soundfile
}
}

function bindsound(tag, soundfile, masterElement){
if (!window.event) return
var source=event.srcElement
while (source!=masterElement && source.tagName!="HTML"){
if (source.tagName==tag.toUpperCase()){
playsound(soundfile)
break
}
source=source.parentElement
}
}

</script>


<a href="#" onMouseover="playsound(soundfile)">Example 1</a>

<a href="#" onMouseover="playsound('different.wav')">Example 2</a>