Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Mute audio

  1. #1
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mute audio

    Hello,

    I have a website that when visited, automatically starts a midi or wav file. I would like to add a MUTE icon or button for visitors to use if preferred. If you know of any code or script that would enable such a feature, it would be greatly appreciated.

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's a bad idea to have music start on entry anyway. Use a "play" button.
    Code:
    <embed id="mySound" src="mySound.mid" loop="false" autostart="false" hidden="true">
    <button onclick="document.getElementById('mySound').play();">Play</button>
    <button onclick="document.getElementById('mySound').stop();">Stop</button>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Twey, I'm shocked! That is an IE only solution! For what it is, elegant though. Anyways, if jester wants something a bit more robust, he should check out this thread.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Really? Shows how much I use sound in sites! I read a page that said that was a Netscape solution that would now work with IE too. Last time I use that one!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    Really? Shows how much I use sound in sites! I read a page that said that was a Netscape solution that would now work with IE too. Last time I use that one!
    Don't feel too bad, it used to work in NS. I think it may still work in NS and even perhaps FF if there are no audio plugins added like QT, etc.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I've researched this sound business a bit more and Twey's method is better than I thought. But, the buttons need to be like so:

    Code:
    <button onclick="document.getElementById('mySound').Play();">Play</button>
    <button onclick="document.getElementById('mySound').Stop();">Stop</button>
    Capitalization counts in Mozilla and Opera.

    Added later - Oh, and I just discovered that Opera needs the enablejavascript="true" attribute set for the embed:

    Code:
    <embed id="mySound" src="mySound.mid" loop="false" autostart="false" hidden="true" enablejavascript="true">
    Last edited by jscheuer1; 01-31-2006 at 07:39 AM. Reason: add Opera fix
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, phew. Gave me a scare there, John
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Sep 2006
    Location
    south jersey
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Mute Audio html

    Hi, I'm new here, and trying to implement your music on/off (mute audio) html.

    I thought I did it correctly, but evidently not!

    Could you, would you, please look here and see what I'm doing wrong? I think it's got to do with the:
    getElementById portion of it. Self taught, pls. excuse!!

    .... forever indebted!!

    ger

    here is the page:

    http://www.bayatlanticsymphony.org/intro3.htm

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    document.getElementById('music/bas3.mp3')
    Should be:
    Code:
    document.getElementById('mySound')
    I'm also self-taught, that's no excuse
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Umm... Just a question. How can you dynamically change the source of "mySound"?
    This is what I came up with, but it doesn't work (as usual).
    Code:
    <embed id="mySound" src="mySound.mid" loop="false" autostart="false" hidden="true" enablejavascript="true">
    <button onclick="document.getElementById('mySound').src = 'song2.mp3';">Switch Song</button>
    <button onclick="document.getElementById('mySound').Play();">Play</button>
    - Mike

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
  •