简体   繁体   English

音频的播放进度-SoundJS

[英]playback progress of audio - SoundJS

How do I get continual playback progress of an audio file, using SoundJS? 如何使用SoundJS获得音频文件的连续播放进度?

I need to animate a graphic matching to play progess. 我需要为图形匹配设置动画以播放进度。

I have looked at the documentation and cannot see a playback progress event. 我查看了文档,但看不到播放进度事件。

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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM