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 to the CF scene
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preloading my audio file in html

    I'm currently using the below way to play sound effect on my website. I need the sound to play out everytime I received a protocol from my slave device:
    Code:
    <script>
    function RxProtocol()
    {
        playSound('audio123.wav');
    }
    
    function playSound(soundfile) 
    {
        document.getElementById("dummy").innerHTML=
        "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
    }
    </script>
    
    <body>
    <span id="dummy"></span>
    </body>
    But seems like this way the audio played is delayed everytime. After I received my protocol for 2 seconds, the audio only played.

    Is it because I did not preload my audio? Could you guys teach me how to modify my code and make it into preload enable?

  • #2
    Regular Coder Nerevarine's Avatar
    Join Date
    Jan 2013
    Location
    Phendrana Drifts, Tallon IV, W-Class
    Posts
    285
    Thanks
    0
    Thanked 17 Times in 17 Posts
    Blog Entries
    3
    If I'm not mistaken, this should be in JavaScript.
    Time kills us in our sleep and we watch it happen in our dreams. -K.K.
    THE END-ALL PROGRAMMING REFERENCE: CLICK HERE (Courtesy of Major Payne)
    My username was previously L0adOpt1c. :: Please read this before posting in the HTML/CSS forum.
    Validate your HTML here and your CSS here. :: Need basic HTML/CSS tutorials? Click here, don't post about it.


  •  

    Posting Permissions

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