Results 1 to 10 of 10

Thread: Sound Rollover, stop sound on mouseout

  1. #1
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Sound Rollover, stop sound on mouseout

    1) Script Title: DOM Image and Sound Rollover v4.0

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex15/domroll.htm

    3) Describe problem: I am using the sound rollover effect on the image of a wolf. On mouseover, the wolf throws his head up and the sound effect is a beautiful howl. However, on mouseout, the howl continues while the wolf's head returns to its original position. Is there a way to make the sound (howl) stop on mouseout?

    Any help would be greatly appreciated.
    Last edited by Nightwing308; 12-05-2014 at 12:16 AM.

  2. #2
    Join Date
    Aug 2009
    Location
    utf-8
    Posts
    205
    Thanks
    4
    Thanked 7 Times in 7 Posts

    Default

    Can you post the code you have so far?
    An inline div is a freak of the web and should be beaten until it becomes a span

  3. #3
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by FrickenTrevor View Post
    Can you post the code you have so far?

    On the image:
    <img border="0" src="HowlingWolf1.jpg" class="domroll HowlingWolf1a.jpg" data-sound="wolfhowl1.mp3, wolfhowl1.ogg, wolfhowl1.wav" width="300" height="350">

    and the code for the provided .js file inserted at the very end of the <BODY> section:
    <script src="chrisdomroll.js">

    /****************************************************
    * DOM Image rollover v4.0: By Chris Poole http://chrispoole.com
    * Script featured on http://www.dynamicdrive.com
    * Keep this notice intact to use it :-)
    ****************************************************/

    </script>


    as instructed on the script's page http://www.dynamicdrive.com/dynamicindex15/domroll.htm

    It works well, both the image rollover AND the sound, but I can't figure out how (where) to modify the code in the .js file, so that the sound stops when the mouse moves off the image.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    The script should already do that actually, cease playing the audio file immediately onmouseout of the image. I tried this with a long music file as well, and onmouseout the music stopped.
    DD Admin

  5. #5
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Maybe I have something wrong in the code somewhere, but my wolf howl does NOT stop when I move the mouse off the image.
    I've uploaded a test page to see if it's just a problem when I view it locally, but it still does it online too (in IE, FF, Chrome, Opera and Safari).
    The link to my sound test is here http://www.nightwingsgraphics.com/So...soundtest.html, if you could maybe have a look at it and see if the howl stops for you when the mouse moves off the image (the wolf's head goes back down).

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I downloaded just wolfhowl1.mp3 and tested it with the script, which does seem to immediately stop the playback onmouseout. On your page it doesn't though. It might have something to do with the fallback audio files you've also defined inside the IMG tag. Try removing those so you're just left with the .mp3 version and see what happens.
    DD Admin

  7. #7
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Okay, here is what I tested, and the results:

    I created 3 separate pages -
    http://www.nightwingsgraphics.com/So...oundtest2.html calls ONLY the .mp3 sound file
    http://www.nightwingsgraphics.com/Soundtest/soundtest3.html calls ONLY the .wav sound file
    and
    http://www.nightwingsgraphics.com/So...oundtest4.html calls ONLY the .ogg sound file

    In ALL instances, the howl continues on mouseout, but some Browsers don't play the howl at all unless the specific sound file format they require is in the code.

    IE - plays ONLY #2 (the page with the mp3 sound file)
    SAFARI - plays ONLY #2 and #3 (the pages with the .mp3 and the .wav sound files)
    CHROME - plays ONLY #3 and #4 (the pages with the .wav and .ogg sound files)

    Firefox and Opera Browsers play all 3 test pages, BUT (as mentioned) the sound on all the test pages continues on mouseout

    What am I missing??????

  8. #8
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    For my own testing I used the following HTML markup:

    Code:
    <!doctype html>
    
    <img src="original.jpg" class="domroll hover.jpg" data-sound="wolfhowl1.mp3" />
    
    <script src="chrisdomroll.js">
    
    /****************************************************
    * DOM Image rollover v4.0: By Chris Poole http://chrispoole.com
    * Script featured on http://www.dynamicdrive.com
    * Keep this notice intact to use it :-)
    ****************************************************/
    
    </script>
    and the attached chrisdomroll.js, which is a slightly modified version of the .js file I had attached in another thread of yours requesting that the audio file loop continuously while the mouse is over the image.
    Attached Files Attached Files
    DD Admin

  9. #9
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    And that works...AND explains why it didn't work for me because I was using the original chrisdomroll.js file that I had downloaded from
    http://www.dynamicdrive.com/dynamicindex15/domroll.htm

    I retested it, and with your modified chrisdomroll.js file the sound stops on mouseout, with the original .js file the sound continues.
    So, once again a BIG THANKS. You're AWESOME!

  10. #10
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    At the possibility that you might want to strangle me now...I've come across a little "glitch" with the modified .js file. The sound works perfect, just as I needed it to, and so does the mouseover effect on the image of the wolf.
    HOWEVER, on the same page are also navigation buttons with a mouseover effect. They light up on mouseover and go dim again on mouseout, but have NO sound effect attached to them.This works fine with the original chrisdomroll.js file, BUT with the modified version that allows the sound to stop on mouseout, the navigation buttons that have no sound effect continue to stay in their mouseover (highlighted) state on mouseout (at least until the page is reloaded).

    I've added one button to a soundtest page here
    http://www.nightwingsgraphics.com/So...oundtest1.html
    so you can see what I mean.

    I tried just adding data-source="" to the domroll code of the button, but that doesn't fix the problem. Do I need to create a "silent" soundfile for the buttons or is there a different way to correct this?

Similar Threads

  1. Sound Rollover, continue sound until mouseout
    By Nightwing308 in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-18-2014, 12:10 PM
  2. stop sound when closing div
    By audiogirl in forum JavaScript
    Replies: 0
    Last Post: 05-17-2009, 10:27 PM
  3. on Close, stop sound
    By Paloozaparty in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-24-2007, 07:01 PM
  4. Replies: 0
    Last Post: 10-16-2005, 11:23 PM
  5. Stop a embedded sound with a link (not with a stop-button)
    By pepito in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 10-16-2005, 11:23 PM

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
  •