org.osmf.metadata

# TimelineMetadata - AS3 OSMF

Package | org.osmf.metadata
Class | public class TimelineMetadata
Inheritance | TimelineMetadata Metadata EventDispatcher Object

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

The TimelineMetadata class encapsulates metadata associated with the timeline of a MediaElement.

TimelineMetadata uses the TimelineMarker class to represent both keys and values (i.e. a TimelineMarker will be stored as both key and value). A TimelineMetadata object dispatches a TimelineMetadataEvent when the currentTime property of the MediaElement's TimeTrait matches any of the time values in its collection of TimelineMarker objects.

View the examples

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | keys : Vector.<String> [read-only] The keys stored in this Metadata object. | Metadata
|  | numMarkers : int [read-only] The number of TimelineMarker objects contained within this object. | TimelineMetadata

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | TimelineMetadata(media:MediaElement) Constructor. | TimelineMetadata
|  | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | EventDispatcher
|  | addMarker(marker:org.osmf.metadata:TimelineMarker):void Adds the specified TimelineMarker to this object. | TimelineMetadata
|  | addValue(key:String, value:Object):void Stores the specified value in this Metadata object, using the specified key. | Metadata
|  | dispatchEvent(event:Event):Boolean Dispatches an event into the event flow. | EventDispatcher
|  | getMarkerAt(index:int):org.osmf.metadata:TimelineMarker Returns the TimelineMarker at the specified index. | TimelineMetadata
|  | getValue(key:String):* Returns the value associate with the specified key. | Metadata
|  | hasEventListener(type:String):Boolean Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | EventDispatcher
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void Removes a listener from the EventDispatcher object. | EventDispatcher
|  | removeMarker(marker:org.osmf.metadata:TimelineMarker):org.osmf.metadata:TimelineMarker Removes the specified TimelineMarker from this object. | TimelineMetadata
|  | removeValue(key:String):* Removes the value associated with the specified key from this Metadata object. | Metadata
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object
|  | willTrigger(type:String):Boolean Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | EventDispatcher

Events
Click for more information on events
Hide Inherited Events
Show Inherited Events

| Event | Summary | Defined By
--- | --- | --- | ---
|  | activate | [broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active. | EventDispatcher
|  | deactivate | [broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher
|  | markerAdd | Dispatched when a TimelineMarker is added to this object. | TimelineMetadata
|  | markerDurationReached | Dispatched when the currentTime property of the MediaElement associated with this TimelineMetadata has reached the duration offset of one of the TimelineMarkers in this TimelineMetadata. | TimelineMetadata
|  | markerRemove | Dispatched when a TimelineMarker is removed from this object. | TimelineMetadata
|  | markerTimeReached | Dispatched when the currentTime property of the MediaElement associated with this TimelineMetadata has reached the time value of one of the TimelineMarkers in this TimelineMetadata. | TimelineMetadata
|  | valueAdd | Dispatched when a new value is added to the Metadata object. | Metadata
|  | valueChange | Dispatched when a value within the Metadata object changes. | Metadata
|  | valueRemove | Dispatched when a value is removed from the Metadata object. | Metadata

Property Detail

### numMarkers

property

`numMarkers:int` [read-only]

The number of TimelineMarker objects contained within this object.

Implementation
`public function get numMarkers():int`
Constructor Detail

### TimelineMetadata

()
Constructor

`public function TimelineMetadata(media:MediaElement)`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Constructor.

Parameters

| `media:MediaElement` — The media element this timeline metadata applies to.

Throws

| `ArgumentError` — If the media argument is null.

Method Detail

### addMarker

()
method

`public function addMarker(marker:org.osmf.metadata:TimelineMarker):void`

Adds the specified TimelineMarker to this object. This class maintains the TimelineMarkers in time order. If another TimelineMarker with the same time value exists within this object, then the existing value will be overwritten.

Parameters

| `marker:org.osmf.metadata:TimelineMarker` — The marker to add.

Throws

| `ArgumentError` — If marker is null or specifies an invalid time.

### getMarkerAt

()
method

`public function getMarkerAt(index:int):org.osmf.metadata:TimelineMarker`

Returns the TimelineMarker at the specified index. Note that the markers are sorted by time.

Parameters

| `index:int` — The index of the marker to return.

Returns

| `org.osmf.metadata:TimelineMarker`

### removeMarker

()
method

`public function removeMarker(marker:org.osmf.metadata:TimelineMarker):org.osmf.metadata:TimelineMarker`

Removes the specified TimelineMarker from this object.

Parameters

| `marker:org.osmf.metadata:TimelineMarker` — The marker to remove.

Returns

| `org.osmf.metadata:TimelineMarker`

Throws

| `ArgumentError` — If marker is null.

Event Detail

### markerAdd

Event

Event Object Type: `org.osmf.events.TimelineMetadataEvent`
property TimelineMetadataEvent.type = `org.osmf.events.TimelineMetadataEvent.MARKER_ADD`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Dispatched when a TimelineMarker is added to this object.

The TimelineMetadataEvent.MARKER_ADD constant defines the value of the type property of the event object for a markerAdd event.

### markerDurationReached

Event

Event Object Type: `org.osmf.events.TimelineMetadataEvent`
property TimelineMetadataEvent.type = `org.osmf.events.TimelineMetadataEvent.MARKER_TIME_REACHED`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Dispatched when the currentTime property of the MediaElement associated with this TimelineMetadata has reached the duration offset of one of the TimelineMarkers in this TimelineMetadata.

The TimelineMetadataEvent.MARKER_TIME_REACHED constant defines the value of the type property of the event object for a markerTimeReached event.

### markerRemove

Event

Event Object Type: `org.osmf.events.TimelineMetadataEvent`
property TimelineMetadataEvent.type = `org.osmf.events.TimelineMetadataEvent.MARKER_REMOVE`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Dispatched when a TimelineMarker is removed from this object.

The TimelineMetadataEvent.MARKER_REMOVE constant defines the value of the type property of the event object for a markerRemove event.

### markerTimeReached

Event

Event Object Type: `org.osmf.events.TimelineMetadataEvent`
property TimelineMetadataEvent.type = `org.osmf.events.TimelineMetadataEvent.MARKER_TIME_REACHED`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Dispatched when the currentTime property of the MediaElement associated with this TimelineMetadata has reached the time value of one of the TimelineMarkers in this TimelineMetadata.

The TimelineMetadataEvent.MARKER_TIME_REACHED constant defines the value of the type property of the event object for a markerTimeReached event.
Examples How to use this example
TimelineMetadataExample.as
Copy

    package
    {
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;

        import org.osmf.elements.VideoElement;
        import org.osmf.events.MediaElementEvent;
        import org.osmf.events.TimelineMetadataEvent;
        import org.osmf.media.MediaPlayerSprite;
        import org.osmf.media.URLResource;
        import org.osmf.metadata.CuePoint;
        import org.osmf.metadata.TimelineMetadata;

        public class TimelineMetadataExample extends Sprite
        {
            public function TimelineMetadataExample()
            {
                super();

                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP_LEFT;

                var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
                var urlResource:URLResource = new URLResource("rtmp://cp67126.edgefcs.net/ondemand/mp4:mediapm/osmf/content/test/cuepoints/spacealonehd_sounas_640_with_nav.f4v");
                videoElement= new VideoElement();
                videoElement.resource = urlResource;
                videoElement.addEventListener(MediaElementEvent.METADATA_ADD, onMetadataAdd);

                addChild(mediaPlayerSprite);
                mediaPlayerSprite.media = videoElement;
            }

            private function onMetadataAdd(event:MediaElementEvent):void
            {
                if (event.namespaceURL == CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE)
                {
                    var timelineMetadata:TimelineMetadata = videoElement.getMetadata(CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE) as TimelineMetadata;
                    timelineMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REACHED, onCuePoint);
                }
            }

            private function onCuePoint(event:TimelineMetadataEvent):void
            {
                var cuePoint:CuePoint = event.marker as CuePoint;
                trace("Cue Point at " + cuePoint.time);
            }

            private var videoElement:VideoElement;
        }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00