user2706772
user2706772

Reputation: 81

playback progress of audio - SoundJS

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

Answers (1)

user2706772
user2706772

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

Related Questions