preloading audio files

前端 未结 3 1491
日久生厌
日久生厌 2021-01-03 08:21

I want to preload audio files in my website. I am using the following code in html page.



        
相关标签:
3条回答
  • 2021-01-03 08:44

    Have not checked though, but can you preload the file doing something like:

    <EMBED NAME="mySound" SRC="cheer.swf" 
    LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE style="height:0px; width:0px">
    
    0 讨论(0)
  • 2021-01-03 08:52

    For the HTML5 audio tag the auto play is a boolean value:

    <audio controls="controls" autoplay="autoplay">
      <source src="song.ogg" type="audio/ogg" />
      <source src="song.mp3" type="audio/mpeg" />
      Your browser does not support the audio element.
    </audio>
    

    As for the swf files you should check that the autoplay attribute is not set hardcoded in each of this files.

    0 讨论(0)
  • 2021-01-03 08:57

    According to http://kb2.adobe.com/cps/127/tn_12701.html the parameter name you're looking for (for the swf 'embed' tags) is 'play', not 'autostart'. Therefore, change them to:

    <embed src="cheer.swf" hidden="true" play="false" style="height:0px; width:0px" />
    

    You could also put them within object tags and then use:

    <param name="play" value="false" />
    

    I've tested this myself, and it works. As for the tags for iPad Safari, the HTML5 audio tag has an attribute called 'preload', which when set to 'auto' should preload the files as you want. Try:

    <audio src="doowip.wav" type="audio/wav" preload="auto" />
    

    I hope this helps.

    0 讨论(0)
提交回复
热议问题