SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Background Music

    Hi, I would like one of my dynamic pages to have background music, but when changed to a different tab I would like that music to stop.

    If I just embed normally, the music doesn't stop when changing to a different tab. Is there a way to stop sound in the code?

    So for example, something like:

    <div id=tab1><music1 plays!>text</div>
    <div id=tab2><music1 stops!><music2 plays!>text</div>

    I'm open to using flash solutions if that's what it takes, but I don't want to have controls, all the sound controls should be done in the code.

    Thanks in advance!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    I don't think that it's possible to tell from javascript whether the display screen is visible or not.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm now currently using soundmanager.

    http://www.schillmania.com/projects/soundmanager2/

    And I have it almost working. I just need a way to change the sound on tab change.

    I did <div id=tab2><music1 stops!></div><script>soundManager.pause('mySound');</script>

    and this does not work. I suspect it's because my tabs aren't dynamically loaded. Is there some other way?

    Thanks.


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
  •