Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    55
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Want to mute sound effects...

    I am using a JS code to populate a sound FX array where the sounds are then activated through various form element event handlers.

    Can this code be used (and how) to create an empty array in order to make use of a 'MUTE' button on the site. Or am I, once again, waaaay off here?

    Code:
    var soundfile=["cancel_a_sound.wav","Rolling_Dice.wav","SWOOSH.wav","BEEPIC.wav","Coins 1.wav","Coins 5.wav","Coins 10.wav","Coins 20.wav","Coins 50.wav","Coins 100.wav","Coins 500.wav","Coins_1000.wav",
    				"LOGOSTIN.wav","Enter_Access_Code.mp3","Command_Codes_Verified.mp3","Transfer_Complete.mp3","Stand_By.mp3","Logs_Accessed.mp3","Coins 5000.wav","Coins 1000.wav",
    				"Affirmative.mp3","Emergency_Power_Engaged.mp3","Airplane_Down.wav","Specify_Parameters.mp3","Coins_Lots.mp3","Data_Link.mp3","Priority_One.mp3",
    				"Classic_Intercom_Whistle.mp3","Emergency_Power_Engaged.mp3","Live_Long_And_Prosper.mp3","Coins_Medium.mp3","Console_Beep_1.mp3","Console_Beep_2.mp3","Console_Beep_3.mp3",
    				"Console_Beep_4.mp3","Console_Beep_5.mp3","Console_Beep_6.mp3","Cruiseship_Down.wav","Train_Down.wav","Bus_Down.wav","Car_Down.wav","Large_Industrial_Fan_Loop_9_seconds.wav",
    				"Transforming_Sound.mp3","Tiger.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
    }
    }
    Any assistance would be great as this is the VERY LAST piece I am adding to my OFFLINE boardgame-playtesting site.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    Can't you just set the audio volume to zero? Using google also turned up
    Code:
    AudioListener.volume = 0;
    and
    Code:
    AudioListener.pause = true;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •