开发者

Check if song is buffering in AS3

开发者 https://www.devze.com 2023-01-03 05:08 出处:网络
I have the following piece of code: var song:Sound; var sndChannel:SoundChannel; var context:SoundLoaderContext = new SoundLoaderContext(2000);

I have the following piece of code:

var song:Sound;
var sndChannel:SoundChannel;
var context:SoundLoaderContext = new SoundLoaderContext(2000);

function songL开发者_开发问答oad():void {
    song.load(new URLRequest(songs[selected]),context);
    sndChannel = song.play();
}

Now I want to be able to check if the song is buffering or not. Is there a way to do this? Or should I approach it differently?


Seems like you could use the isBuffering property of the Sound object.

Maybe you could check it periodically with a Timer or an Event.EnterFrame listener, as long as the sound has not been completely downloaded (i.e. until Event.COMPLETE fires). After that point, it makes no sense to check isBuffering, for obvious reasons, so you could remove the Timer or EnterFrame.

0

精彩评论

暂无评论...
验证码 换一张
取 消