25
Jul
08

Create an FLV thumbnail image from VideoDisplay during runtime in Flex

Here’s a Little trick that shows you how to generate an image thumbnail during runtime from a VideoDisplay component, you can than create a server side proxy to save the image as a file or just use it as it is. Enjoy.


    <mx:Script>
        <![CDATA[
			import mx.events.VideoEvent;

			private function playheadUpdateHandler(event:VideoEvent):void {

			    var bmData:BitmapData = new BitmapData(100, 100);
			    bmData.draw(event.target as DisplayObject);

			    var bm:Bitmap = new Bitmap(bmData);
			    img.source = bm;
			}
        ]]>
    </mx:Script>

    <mx:Canvas>

		<mx:VideoDisplay id="videoDisplay"
			source="someFlvVideo.flv"
			playheadUpdate="playheadUpdateHandler(event); event.target.stop();"
			visible="false" width="100" height="100" />
		<mx:Image id="img" />
    </mx:Canvas>

3 Responses to “Create an FLV thumbnail image from VideoDisplay during runtime in Flex”


  1. 1 CyMeP Aug 23rd, 2008 at 7:02 am

    Very interesting, thank you !

  2. 2 Martin Widjaja Feb 27th, 2009 at 3:02 am

    Thanks, this is very useful trick =)

  3. 3 R Hillum Mar 29th, 2009 at 11:05 am

    Sadly the code does not work when you specify a remote flv location e.g youtube.