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
    Jul 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Stop sound script?

    I am working in Dreamweaver and I have embeded a sound to play when the page loads. I want to use an image as a button to allow the user to stop the sound. Is this possible? Would it be easier to just use java for the whole sound load/sound stop business?

    Sorry to ask such a simple question, this is much easier in Flash with the stop sound command.

    Thanks

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    i downloaded this script somewhere...

    Add this script to you page at the bottom right before the closing body tag:
    <script LANGUAGE="JavaScript">
    <!--//
    audio=["sound1.wav","sound2.wav"]

    function playSound(x){
    (document.all) ? snd.src=document.embeds[x].src : document.embeds[x].play()
    }
    function stopSound(x){
    (document.all) ? snd.src="" : document.embeds[x].stop()
    }

    var audioStr='<bgsound id="snd" />\n'
    for (var i in audio)
    audioStr+='<embed name="audio'+ i +'" src="'+ audio[i] +'" autostart="false" hidden="true" />\n'
    document.write(audioStr)
    //-->
    </script>

    Then your links would look like this:

    <a href="stuff.htm" onmouseover="playSound(1)" onmouseout="stopSound(1)">stuff</A>

    with the above example you would hear sound2.wav whent he mose moves over the link and will stop when it moves out.


    To have more than the two sounds add all the sounds you want to choose from here:

    audio=["sound1.wav","sound2.wav","anotherSong.wav","moreSongs.wav"]

    Just put as many songs in there as you like an remeber that they go in order like this:

    audio=[0,1,2,3,4,5,6...

    so with the above example if my link said:

    playSound(3) it would play moresongs.wav


  •  

    Posting Permissions

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