« Listening for an FLV file's metadata using the VideoDisplay control in Flex (Flex 2 edition) | Main | Using embedded fonts with the Flash CS3 ComboBox control »

Listening for an FLV file's metadata using the VideoDisplay control in Flex (Flex 3 edition)

The following example shows how you can use the metadataReceived event (MetadataEvent.METADATA_RECEIVED constant) to detect when the VideoDisplay has parsed the metadata from an FLV file in Flex 3.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.events.MetadataEvent;
            import mx.utils.ObjectUtil;

            private function onMetaData(evt:MetadataEvent):void {
                textArea.text = ObjectUtil.toString(evt.info);
            }
        ]]>
    </mx:Script>

    <mx:VideoDisplay id="videoDisplay"
            source="http://www.helpexamples.com/flash/video/clouds.flv"
            metadataReceived="onMetaData(event);" />

    <mx:TextArea id="textArea"
            editable="false"
            width="100%"
            height="100%" />

</mx:Application>

For more information on the VideoDisplay control in Flex 2, see http://livedocs.adobe.com/flex/3/langref/mx/controls/VideoDisplay.html.

For an example of detecting the metadata in Flex 2, see "Listening for an FLV file's metadata using the VideoDisplay control in Flex (Flex 2 edition)". For an example of displaying an FLV in Flex using the NetConnection, NetStream, and Video classes, see "Displaying a video in Flex using the NetConnection, NetStream, and Video classes" (blog.flexexamples.com).

Comments

Hi!
Nice example!
And how I can add some metadata to flv file and save it?

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)