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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts

    preloading sound

    Hello,
    I've searched all over the internet and I just did a quick search here, but I couldn't find my answer. How would I preload several sound files? I want the files to preload as soon as the page is loaded. Then, when the user activates the sound, it will play without any delay.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In the past we used the <embed> tag...
    But I would suggest that you look into using the <object> tag for forward compatability....

    Code:
    <embed autostart="false" hidden="true" src="mySound.wav">
    .....Willy

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Does <object> work with older browsers? What if I wanted to preload several sounds? Would I just do the following:?
    Code:
    <embed autostart="false" hidden="true" src="mySound.wav">
    <embed autostart="false" hidden="true" src="mySound2.wav">
    <embed autostart="false" hidden="true" src="mySound3.wav">
    Is this the most reliable and effective way to preload sounds? What's wrong with a javascript version?

    Thanks for replying, sorry if I ask tooo many questions.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,732
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    "I want the files to preload as soon as the page is loaded. Then, when the user activates the sound, it will play without any delay."

    This works in IE only:-

    <EMBED src="boathorn.wav" hidden="true" autostart="false" name="horn">
    <bgsound id="sound">

    <SCRIPT language="JavaScript">
    function playhorn()
    {
    if (document.all) {document.all.sound.src = "boathorn.wav"}
    }
    </SCRIPT>

    When the function playhorn() is called the horn sounds.

    You could preload several sounds by making bgsound id="sound2" etc.


  •  

    Posting Permissions

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