Archive for October, 2007

FLVPlayback FLV Preloader

Tuesday, October 16th, 2007

Here’s a way to Preload flv files before you play them in FLVPlayback component.

import mx.video.*;

var listenerObject:Object = new Object();

my_FLVPlybk.progressInterval = 001;
my_FLVPlybk.autoPlay = false;

listenerObject.progress = function(eventObject:Object) :Void {

var perc = Math.floor(eventObject.bytesLoaded * 100 / eventObject.bytesTotal);
//implement you loading visual representation here

if(perc == 100)
my_FLVPlybk.play();

}

my_FLVPlybk.addEventListener("progress", listenerObject);
my_FLVPlybk.load("yourflv.flv");

You can hide the player while its getting downloaded and show it when its fully downloaded. Make sure to set the autoplay option to false.

Happy coding :)