How to take screenshots of a Flex Spark VideoDisplay?

I want to build a component, where the user can play a video in a Flex Spark VideoDisplay. There will be a button and whenever the button is pressed, I want to save the current time of the VideoDisplay plus a screenshot. The screenshot needs to be someway saved, because I want to display all times and screenshots in a DataGrid (screenshots should appear when the user hovers a time in the DataGrid).

So, how can I take screenshots of the Spark VideoDisplay and save/display them?


You can take snapshots a few ways, this way just uses the ImageSnapshot class, but you could do it by manually drawing the bitmap of the video display if you'd like. Here's a sample:


<?xml version="1.0" encoding="utf-8"?>
    width="100" height="100" creationComplete="trace(data)">

    <mx:Image source="{}" width="100%" height="100%"/>


Sample App

<?xml version="1.0" encoding="utf-8"?>



            public function takeSnapshot():void
                var snapshot:BitmapData = ImageSnapshot.captureBitmapData(videoDisplay);
                var bitmap:Bitmap = new Bitmap(snapshot);

        <s:VerticalLayout horizontalAlign="center"/>

    <s:VideoDisplay id="videoDisplay"
        width="400" height="300"/>

    <s:Button id="button" click="takeSnapshot()"/>

    <s:List id="list" horizontalCenter="0" width="100%" itemRenderer="SnapshotRenderer">

To accomplish exactly what you were describing (take snapshot and save snapshot), you could store those in an array in that takeSnapshot method, or you could loop through the list.dataProvider do get the bitmaps. Then you'd just need to pass them to a backend language (ruby, python, php...) to save.

Hope that helps, Lance

use the JPEGEncoder in flex to convert it to bytearray, and then encode the byte array using the b64encoder as follow:

var jpg:JPEGEncoder = new JPEGEncoder();
var ba:ByteArray = jpg.encode(bitmapData);        

var b64encoder:Base64Encoder = new Base64Encoder();
var b64String:String = b64encoder.flush();

Now you can pass your b64String to your server via HTTP post method :)

Need Your Help

WebService How do i pass parameters

c# web-services rest windows-phone-8.1

I am using the following webservice function call I found on another question here but I am confused as how to pass parameters its says to pass it as json but normally a php service paramerter is j...

clearInterval wont clear the interval

javascript jquery clearinterval

hi there i have this small script that changes the background image with a fadein/out effect,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.