Check if song is buffering in AS3
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.
精彩评论