Reputation: 81
How do I get continual playback progress of an audio file, using SoundJS?
I need to animate a graphic matching to play progess.
I have looked at the documentation and cannot see a playback progress event.
Upvotes: 1
Views: 348
Reputation: 81
The answer is to roll you own:
//declare global var for Sound instance
var soundInstance;
function startPlayback(){
soundInstance = createjs.Sound.play("audio/sound.mp3", {loop: 0});
createjs.Ticker.addEventListener("tick", tick);
createjs.Ticker.setInterval(TICK_FREQ);
}
function tick(evt) {
var progress = soundInstance.position/soundInstance.duration;
//do something with progress
}
Upvotes: 3