Friday, February 13, 2009

FLVPlayback Problem

Flash's FLVPlayback component does not seem to be too solid. One common problem is when you close it out and kill it before it loads the video, the video seems to still sneak its way in and play anyway. Even though there is no visuals, you still hear audio playing in the background. One solution was to call the SoundMixer.stopAll() function but not only does this only duct tape the problem, it kills all sounds.

I had a problem with with the FLVPlayback component recently. Real weird. When clicking on a button, it would create a new FLVPlayback component and play the video. The video will load and play fine the first time but on the network it would hang the second time for about 30 seconds then load and play. The third, fourth, fifth times, loaded fine again. After digging through the problem, stopping and closing the FLVPlayback, setting all variables to null, calling the System.gc()... still the problem existed.

Finally took some time to really go through the API docs a bit closer and noticed there was a way to get a hold of the VideoPlayer within. So, got the problem fixed by stopping and closing the video player, then stop and nullify the FLVPlayback, and finally collect the garbage.

var vidPlayer:VideoPlayer = myFLVPlayback.getVideoPlayer(myFLVPlayback.activeVideoPlayerIndex);
vidPlayer.stop();
vidPlayer.close();
myFLVPlayback.stop();
myFLVPlayback = null;
System.gc();

2 comments:

David said...

Thanks a bunch. I had exactly the same problem and it bugged me for a few hours and was never able to track down what the problem was. This fixed it right up.

Anonymous said...

Okay.. I spent seriously too much time searching on google all the flash forums looking for this information.

Well done! Thanks for solving my actionscripting issues :-)