Reputation: 5557
I want to preload audio files in my website. I am using the following code in html page.
<embed src="cheer.swf" hidden="true" autostart=false style="height:0px; width:0px">
<embed src="click.swf" hidden="true" autostart=false style="height:0px; width:0px">
<embed src="doowip.swf" hidden="true" autostart=false style="height:0px; width:0px">
But still all the audio files are played at the beginning of the page. how can i stop the autoplay of audio files.
Also how can i preload the files for ipad safari?
<audio id="genclick" src="click.wav" type="audio/wav" >
<audio src="doowip.wav" type="audio/wav" >
<audio src="cheer.wav" type="audio/wav" >
the above code not loading the file until i play it from javascript..
document.getElementById("genclick").play();
where am I going wrong??
Upvotes: 4
Views: 3477
Reputation: 21
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.
Upvotes: 1
Reputation: 262
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.
Upvotes: 2
Reputation: 100175
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">
Upvotes: 1