android - JavaScript: Sound not looping on Firefox (Phone/Tablet) -
i cannot life of me sound loop on firefox @ all. i've searched google hours , still feel i'm asking stupid question, there answer out there. @ highly appreciated. thank much!
here have tried:
var newjobaudio = new audio('/audio/newjobalert.mp3'); newjobaudio.loop = true; newjobaudio.play();
edit: updated code (doesn't work still, but, can see have)
var newjobaudio = new audio('/audio/newjobalert.mp3'); audioloop(true); function audioloop(play) { if ( play ) { newjobaudio.addeventlistener('ended', playaudio, false); newjobaudio.play(); } else { newjobaudio.removeeventlistener('ended', playaudio, false); newjobaudio.pause(); } } function playaudio() { newjobaudio.currenttime = 0; newjobaudio.play(); }
edit:
even though tablet/phone firefox works fine mp3 sound breaks after first play. able determine using workaround sound looping using setinterval. when setinterval started looping every 2 sec sound play fine first time break on others. rustam mate! =)
var newjobaudio1 = new audio('/audio/newjobalert.mp3'); var newjobaudio2 = new audio('/audio/newjobalert.mp3'); newjobaudio1.addeventlistener('ended', function(){ this.currenttime = 0; this.pause(); newjobaudio2.play(); }, false); newjobaudio2.addeventlistener('ended', function(){ this.currenttime = 0; this.pause(); newjobaudio1.play(); }, false); newjobaudio1.play(); // start playing
use 2 audios , switch each other
Comments
Post a Comment