HTML5 Audio doesn't play until I physically rotate Nexus 7 -
i'm trying html5 audio sprites working on nexus 7 using android chrome browser. change audio being played, change source of audio player, reload audio player.
i have detect 2 'timeupdate' events make sure audio playing, because html5 audio on android can bit unreliable.
it's 1 part of large page can't post all, setup boils down basically:
<body> <audio id="myaudioplayer" src="audio_1.wav"> <script type=javascript> function changeaudio() { var audioplayer = document.getelementbyid("myaudioplayer"); audioplayer.currentsrc = getnextaudioclip(); audioplayer.load(); audioplayer.play(); audioplayer.addeventlistener('timeupdate', firsttimeupdate, false); } function firsttimeupdate() { this.removeeventlistener('timeupdate', firsttimeupdate, false); this.addeventlistener('timeupdate', secondtimeupdate, false); this.play(); } function secondtimeupdate() { this.removeeventlistener('timeupdate', secondtimeupdate, false); this.addeventlistener('timeupdate', timesliderupdate, false); } </script> </body>
so, works fine first few times. audio changed, 'timeupdate' fires firsttimeupdate(), audio starts playing , 'timeupdate' fires again secondtimeupdate().
but 6th or 7th time change audio, second 'timeupdate' event doesn't fire, secondtimeupdate() never reached, unless rotate nexus 7 90 degrees , rotate again, whereupon audio starts playing, second 'timeupdate' fired, , begins work again.
this continues until change audio 12th or 13th time, same thing observed. getnextaudioclip() function working fine (i.e. it's returning valid audio file).
i'm stumped this. can hazard guess going on here, or why rotating nexus 7 "fixes" it?
edit: ok, after having bit more time play this, seems issue related garbage collection. rotating nexus 7 seems trigger garbage collection on previously-loaded audio sprites, allows new sprite load , play. changing different tab , again this. if audio gc'd automatically somehow, have workaround.
Comments
Post a Comment