javascript - How can I do gapless audio looping with mobile browser? -
it seems i'm unable achieve gapless looping mobile. i've done far:
https://github.com/hivenfour/seamlessloop
- creates gap.
http://www.schillmania.com/projects/soundmanager2/demo/api/
- creates gap.
https://github.com/regosen/gapless-5
- creates gap.
- downloads same audio twice.
https://github.com/floatinghotpot/cordova-plugin-nativeaudio
- creates gap.
html5 audio
- creates gap.
cordova's media plugin
- creates gap.
webaudio
- works!
- for 1.5min audio clip, decoding time > 30 seconds.
- https://code.google.com/p/chromium/issues/detail?id=424174
all above tested mp3 , ogg.
edit:
soundjs's cordova plugin broken , doesn't work;
with html5 if using html5, use loop attribute.
<audio controls loop> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> browser not support audio element. </audio>
it doesn't create gap, check audio file, of audio file has gap @ end.
you can test here, add loop attribute , run page.
with javascript
here alternative using javascript
myaudio = new audio('somesound.ogg'); myaudio.addeventlistener('ended', function() { this.currenttime = 0; this.play(); }, false); myaudio.play();
here javascript create little gap, can overcome playing loop not when audio finished when audio finish. here code.
here want.
myaudio = new audio('http://unska.com/audio/pinknoise.ogg'); myaudio.ontimeupdate= function(i) { if((this.currenttime / this.duration)>0.9){ this.currenttime = 0; this.play(); } }; myaudio.play();
here demo.
Comments
Post a Comment