i have web based game uses html5 audio feature. use loop background music once game (level starts). runs fine, problem i'm facing after 4-5 loops, background music gets distorted resulting in rough music output. how solve issue or limitation in browsers?
since browsers not supporting html5 audio looping functionality, have used javascript this. here code snippet:
bgmusic = new audio('music.mp3'); bgmusic.addeventlistener('ended', function() { this.currenttime = 0; this.play(); }, false); bgmusic.play();
to loop track instead:
var bgmusic = new audio(); bgmusic.loop = true; // enable looping bgmusic.autoplay = true; // autoplay when data ready bgmusic.src = 'music.mp3'; // start loading data
however, if distorted sound, indicates browser bug. suggest reporting vendor.
Comments
Post a Comment