Javascript HTML5 audio - Dont play sound if already playing? -


i have set html audio on site , have set autoplay function after couple of seconds, sound seems loading twice? 1 starts playing straight after other although, 1 ghost , cannot see player it.

how go telling javascript not start playing sounds if there sounds playing?

<audio controls="controls" onloadeddata="var audioplayer = this; settimeout(function() { audioplayer.play(); }, 2000)" }>     <source src="http://www.alanis50.com/music/music.mp3" type="audio/mp3"/>     <source src="http://www.alanis50.com/music/music.ogg" type="audio/ogg"/> </audio> 

the above issue has been solved wanted add flash fallback audio internet explorer , added:

<div id ="audio">  <script>var readingmusic = false; </script> <audio controls="controls" loop="loop" onloadeddata="var audioplayer = this; if (!readingmusic){readingmusic = true;settimeout(function() { audioplayer.play(); }, 2000)}" }>     <source src="http://www.alanis50.com/music/music.mp3" type="audio/mp3"/>     <source src="http://www.alanis50.com/music/music.ogg" type="audio/ogg"/>     <embed type="application/x-shockwave-flash" flashvars="audiourl=http://www.alanis50.com/music/music.mp3&autoplay=true" src="http://www.google.com/reader/ui/3523697345-audio-player.swf" width="400" height="27" quality="best" wmode="transparent"></embed> </audio> </div>  <div id="audiohide"> <audio controls="controls" loop="loop" onloadeddata="var audioplayer = this; if (!readingmusic){readingmusic = true;settimeout(function() { audioplayer.play(); }, 2000)}" }>     <source src="http://www.alanis50.com/music/music.mp3" type="audio/mp3"/>     <source src="http://www.alanis50.com/music/music.ogg" type="audio/ogg"/>     <embed type="application/x-shockwave-flash" flashvars="audiourl=http://www.alanis50.com/music/music.mp3&autoplay=true" src="http://www.google.com/reader/ui/3523697345-audio-player.swf" width="400" height="27" quality="best" wmode="transparent"></embed> </audio>  </div> 

but flash audio behaving how previous audio did javascript not affecting flash embed?

can't have boolean telling browser if there music playing ?

example 2 tags:

<script>var readingmusic = false; </script> <audio controls="controls" onloadeddata="var audioplayer = this; if (!readingmusic){readingmusic = true;settimeout(function() { audioplayer.play(); }, 2000)}" }>     <source src="http://www.alanis50.com/music/music.mp3" type="audio/mp3"/>     <source src="http://www.alanis50.com/music/music.ogg" type="audio/ogg"/> </audio>  <audio controls="controls" onloadeddata="var audioplayer = this; if (!readingmusic){readingmusic = true;settimeout(function() { audioplayer.play(); }, 2000)}" }>     <source src="http://www.alanis50.com/music/music.mp3" type="audio/mp3"/>     <source src="http://www.alanis50.com/music/music.ogg" type="audio/ogg"/> </audio> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -