VideoEvent.BUFFERING_STATE_ENTERED – workaround
The BUFFERING_STATE_ENTERED event of the FLVPlayback component is designed to notify when the instance reaches its buffer threshold and begins the buffering process. Unfortunately, there is one critical state that fails to be reported by this event. If, during normal playback, the buffering threshold is reached, the video should pause and enter the buffering state until the bufferTime value is met. However, while a pause state is entered, buffering is not. Moreover, the buffering property is still false, and stateResponsive is still true. I would definitely assume that in a buffering state these values should be true and false, respectively. Subsuquently, the only way to discern a buffer initiated pause from a user initiated pause is to track all other pause occurences, and flag them as user initiated by tracking a boolean value. If, when the PAUSED_STATE_ENTERED event is fired, that boolean value is false, then you know that a buffering state has been entered.
This is still problematic, no doubt. going about this method of ensuring you are in a buffering state means you absolutely have to catch all occurences of pauses, whether triggered by the FLVPlayback package or by the user,and flag them, to make sure you have isolated buffering related pauses only. Whats more, this renders the bufferingBar property useless, which is designed to connect a Sprite to buffering events, displaying a custom graphic when buffering. I don't recommend using this anyway as doing so removes the ability to control how and when that visual is displayed, but if you DID decide to use it, the use case discussed above is definitely not caught by the class itself - it simply pauses.
If someone is aware of a simpler and/or more conclusively effective workaround, please drop a comment!




July 17th, 2009 - 17:13
I came across the exact same problem which led me to your post here. Basically I’ve also concluded that the bufferingBar component is worthless and doesn’t really behave how I want it to…. seems like it ought to be a class with accessible methods and properties so you could change timing or whatever else… anyway I ended up making my own, doing a boolean to check for pauses not initiated by the video catching up to the buffer threshold, and listening for STATE_CHANGE and checking the .state property of the event to handle different states, rather than doing separate listeners for BUFFERING_STATE_ENTERED, PLAYING_STATE_ENTERED etc.
i.e.
private function doStateChange(e:VideoEvent):void {
if (e.state == “buffering” || e.state == “loading”) {
showBuffer();
}
and so on. Anyway thanks for validating my confusion, your post helped me figure this out.
July 18th, 2009 - 14:59
That’s a clean and simple solution, thanks Brendan!
-Jeff