I am a frontend developer and author based in the UK, specializing in JavaScript development and application architecture. I founded Newtriks Ltd. and have been remotely contracting for the last 10 years for global corporations and venture-backed start-ups. I regularly consult Angular, Backbone, and React, and train programmers in test-driven development. I'm an enthusiastic open source contributor and am the cofounder and lead developer of the live webcasting platform Sayansho Ltd. Please contact me to discuss your specific business requirements.
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 );
}