Results 1 to 4 of 4

Thread: Music Off delay in IE 7- HELP

  1. #1
    Join Date
    Apr 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Music Off delay in IE 7- HELP

    Hi folks, I have a code for music on/off that finally works in all browsers but in IE7 to turn off the sound I have to click the off button many times before it quits the music....
    Can any good soul help me out on this one?
    Hereafter the code, thanks a lot!

    <body id="bodyMain" onload="javascript:soundCtrl('on')">
    <script language="javascript" type="text/javascript">
    var soundSource="../audio/tequila.mp3";
    function soundCtrl(onoff) {
    if(onoff == "off") {
    var sound = el("bgsound");
    if(sound)
    document.getElementById("bodyMain").removeChild(sound);
    }
    else if(onoff == "on"){
    if(el("bgsound")) return;
    var sound = document.createElement("embed");
    sound.setAttribute("src",soundSource);
    sound.setAttribute("hidden",true);
    sound.setAttribute("autostart",true);
    sound.setAttribute("id","bgsound");
    document.getElementById("bodyMain").appendChild(sound);

    }
    }
    function el(id) {
    var el = document.getElementById(id);
    return el;
    }
    </script>
    HTML
    <a href="#" onclick="soundCtrl('off')">shut up&nbsp; |</a>
    <a href="#" onclick="soundCtrl('on')">play on</a>

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Try the old-fashioned way:

    <bgsound id="bg" src="some_music_title.wav" volume="0"></bgsound>

    This may help.

    -magicyte

  3. #3
    Join Date
    Apr 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Music on/off

    Thank for the answer but how do you stop it. I need to have a on /off button

  4. #4
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    To stop it, set the volume to -10000. To do this, here:

    document.getElementById('bg').volume = "-10000";

    Any other questions, comments, or requests? You know what, here:

    Code:
    <a href="#" onclick="document.getElementById('bg').volume = '-10000';">OFF</a>|<a href="#" onclick="document.getElementById('bg').volume = '-10000';">ON</a>
    These up here ^^^ are the functions you need. However, I got this stuff from this:

    Code:
    function BGMSTOP(){
     if (systm == "C"){
      BG.src = "test001.mid"
      BG.volume = -10000
     }else{
      document.embeds[0].stop()
     }
    }
    
    function BGMSTART(){
     if (systm == "C"){
      BG.src = "Soul_Food.mid"
      BG.volume = 0
     }else{
      document.embeds[0].stop()
      document.embeds[0].play(true)
     }
    }
    You can use excerpts of code from here for your needs.

    -magicyte
    Last edited by magicyte; 10-08-2008 at 12:53 AM.

Bookmarks

Posting Permissions

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