TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,993
  • Total Topics: 21,324
  • Online today: 192
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 178
  • Total: 178

Add wave sound to a button?

Started by whoesa, May 14, 2006, 11:08:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

whoesa

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.

G6Cad

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 :)

Arba

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)

bloc

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.

whoesa

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  :)

Crystallas

#5
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.



Crystallas

well.. i tried to help. It doesnt work as well as it did in my head. Maybe someone has a better idea.

bloc

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?

Nokonium


whoesa

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?



bloc

Did you get the paths correct? Not having looked into it, that is many times the cause of trouble.

whoesa

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.


G6Cad

Post it here and let some code master look at it :)

whoesa

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>



This website is proudly hosted on Crocweb Cloud Website Hosting.