Preload audio files

I want to preload the audio files on my website. I am using the following code on an 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 all sound files are played at the top of the page. how can i stop auto play audio files.

Also how can I preload ipad safari files?

 <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 does not load the file until I play it from javascript ..

 document.getElementById("genclick").play(); 

where am i wrong

+4
source share
3 answers

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

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

You can also put them in object tags and then use:

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

I experienced it myself, and it works. As for tags for iPad Safari, the HTML5 tag has an attribute called preload, which when set to β€œauto” should preload the files as you wish. Try:

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

Hope this helps.

+2
source

Not tested, but you can preload the file by doing something like:

  <EMBED NAME = "mySound" SRC = "cheer.swf" 
 LOOP = FALSE AUTOSTART = FALSE HIDDEN = TRUE style = "height: 0px; width: 0px">
+1
source

For HTML5 audio text, automatic playback is a logical 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> 

Regarding swf files, you should check that the autoplay attribute is not set in each of these files.

+1
source

Source: https://habr.com/ru/post/1381433/


All Articles