After 8 seconds, I want to use setTimeout to play an audio file:
setTimeout(function() {
document.getElementById('delayed_play').style.display = 'block';
}, 8 * 1000);
<div id="delayed_play">
The issue is that the audio file doesn't start exactly after 8 seconds due to varying connection speeds that affect the loading time.
Is there a way to load the file paused and instruct it to start playing at 8 seconds?
Here is the audio file along with the remaining script:
<script type="text/javascript">
document.getElementById('delayed_play').style.display = 'none';
</script>
<object height="0" width="40%">
<embed allowscriptaccess="always" height="0" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F14151193%3Fsecret_token%3Ds-OVmfN&show_comments=false&auto_play=true&color=ff7700" type="application/x-shockwave-flash" width="100%"></embed>
</object>
Thank you