Interactive Development specialising in web-applications
How to Take a BitMap Snapshot of an FLV
I needed a quick easy way to take BitMap snapshot of a loaded flv for an app. I thought the easiest way to accomplish this would be to load the FLV into my player and then play a very short snippet, pause the video and then take a snapshot. Here are some snippets of my code to give you an idea of how easy this is to accomplish. Maybe someone has a better way to do this which I would love to hear about:
private var _timer:Timer;
public var bm:Bitmap;
private function initApp():void
{
_timer = new Timer(10, 1);
_timer.addEventListener( TimerEvent.TIMER, pauseSnap );
}
public function play():void
{
ns.play( url );
_timer.start();
}
private function pauseSnap( e:TimerEvent ):void
{
ns.pause();
bm = takeSnapShot( this as DisplayObject );
/**
* 'this' refers to the VideoContainer which extends UIComponent
* the container is simply the FLV so the resulting BitMap will display the FLV
*/
}
private function takeSnapShot( source:DisplayObject ):Bitmap
{
var bmd:BitmapData = new BitmapData( video.width, video.height );
bmd.draw( source );
return new Bitmap( bmd );
}