ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
org.osmf.media 

MediaElement  - AS3 OSMF

Packageorg.osmf.media
Classpublic class MediaElement
InheritanceMediaElement Inheritance EventDispatcher Inheritance Object
Subclasses BeaconElement, CompositeElement, HTMLElement, LoadableElementBase, ProxyElement

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

A MediaElement represents a unified media experience. It may consist of a simple media item, such as a video or a sound. Different instances (or subclasses) can represent different types of media. A MediaElement may also represent a complex media experience composed of multiple items, such as videos, ad banners, SWF overlays, background page branding, etc.

Programmatically, a media element encapsulates a set of media traits and a state space. The media traits represent the capabilities of the media element and are dynamic in nature. At one moment in time a media element might be seekable, at another moment it might not be. For example, this could occur if the media element is a video sequence containing unskippable ads.

A media element operates on a media resource. For example, if the media element represents a video player, the media resource might encapsulate a URL to a video stream. If the media element represents a complex media composition, the media resource URL might be a document that references the multiple resources used in the media composition.

Related API Elements

MediaTraitBase
MediaResourceBase


Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  container : IMediaContainer
[read-only] The media container that this element uses.
MediaElement
  metadataNamespaceURLs : Vector.<String>
[read-only] A Vector containing the namespace URLs for all Metadata objects stored within this MediaElement.
MediaElement
  resource : MediaResourceBase
The media resource that this media element operates on.
MediaElement
  traitTypes : Vector.<String>
[read-only] A Vector of MediaTraitType values representing the trait types on this media element.
MediaElement
Public Methods
 MethodDefined By
  
Constructor.
MediaElement
 Inherited
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
  
addMetadata(namespaceURL:String, metadata:Metadata):void
Adds a Metadata object to this MediaElement under the specified namespace URL.
MediaElement
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
Returns the Metadata object that is stored under this MediaElement with the specified namespace URL.
MediaElement
  
Returns the media trait of the specified type.
MediaElement
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
  
Determines whether this media element has a media trait of the specified type.
MediaElement
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Removes the Metadata object that was stored under this MediaElement with the specified namespace URL.
MediaElement
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Protected Methods
 MethodDefined By
  
Adds a new media trait to this media element.
MediaElement
  
Removes a media trait from this media element.
MediaElement
  
Sets up the traits for this media element.
MediaElement
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
  Dispatched when the element's container property changed.MediaElement
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when an error which impacts the operation of the media element occurs.MediaElement
  Dispatched when a info which impacts the operation of the media element is available.MediaElement
  Dispatched when a Metadata object has been added to this media element.MediaElement
  Dispatched when a Metadata object has been removed from this media element.MediaElement
  Dispatched when a trait is added to the media element.MediaElement
  Dispatched when a trait is removed from the media element.MediaElement
Property Detail

container

property
container:IMediaContainer  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The media container that this element uses.



Implementation
    public function get container():IMediaContainer

metadataNamespaceURLs

property 
metadataNamespaceURLs:Vector.<String>  [read-only]

A Vector containing the namespace URLs for all Metadata objects stored within this MediaElement.



Implementation
    public function get metadataNamespaceURLs():Vector.<String>

resource

property 
resource:MediaResourceBase

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The media resource that this media element operates on.



Implementation
    public function get resource():MediaResourceBase
    public function set resource(value:MediaResourceBase):void

traitTypes

property 
traitTypes:Vector.<String>  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

A Vector of MediaTraitType values representing the trait types on this media element.



Implementation
    public function get traitTypes():Vector.<String>
Constructor Detail

MediaElement

()Constructor
public function MediaElement()

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Constructor.

Method Detail

addMetadata

()method
public function addMetadata(namespaceURL:String, metadata:Metadata):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Adds a Metadata object to this MediaElement under the specified namespace URL.

Parameters

namespaceURL:String — The namespace URL used to store the Metadata.
 
metadata:Metadata — The Metadata to add.

Throws
ArgumentError — if namespaceURL or metadata is null.

addTrait

()method 
protected function addTrait(type:String, instance:org.osmf.traits:MediaTraitBase):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Adds a new media trait to this media element. If successful, dispatches a MediaElementEvent.

Parameters

type:String — The MediaTraitType for the media trait to add.
 
instance:org.osmf.traits:MediaTraitBase — The media trait to add.

Throws
ArgumentError — If either parameter is null, or if the specified type and the type of the media trait don't match, or if a different instance of the specific trait class has already been added.

getMetadata

()method 
public function getMetadata(namespaceURL:String):Metadata

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Returns the Metadata object that is stored under this MediaElement with the specified namespace URL.

Parameters

namespaceURL:String — The namespace URL of the Metadata object to retrieve.

Returns
Metadata

Throws
ArgumentError — If namespaceURL is null.

getTrait

()method 
public function getTrait(type:String):org.osmf.traits:MediaTraitBase

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Returns the media trait of the specified type.

Parameters

type:String — The MediaTraitType for the media trait to return.

Returns
org.osmf.traits:MediaTraitBase — The retrieved trait or null if no such trait exists on this media element.

Throws
ArgumentError — If the parameter is null.

hasTrait

()method 
public function hasTrait(type:String):Boolean

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Determines whether this media element has a media trait of the specified type.

Parameters

type:String — The MediaTraitType for the media trait to check for.

Returns
Booleantrue if this media element has a media trait of the specified class, false otherwise.

Throws
ArgumentError — If the parameter is null.

removeMetadata

()method 
public function removeMetadata(namespaceURL:String):Metadata

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Removes the Metadata object that was stored under this MediaElement with the specified namespace URL.

Parameters

namespaceURL:String — The namespace URL of the Metadata to remove.

Returns
Metadata

Throws
ArgumentError — If namespaceURL is null.

removeTrait

()method 
protected function removeTrait(type:String):org.osmf.traits:MediaTraitBase

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Removes a media trait from this media element. If successful, dispatches a MediaElementEvent.

Parameters

type:String — The MediaTraitType for the media trait to remove.

Returns
org.osmf.traits:MediaTraitBase — The removed trait or null if no trait was removed.

Throws
ArgumentError — If the parameter is null.

setupTraits

()method 
protected function setupTraits():void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Sets up the traits for this media element. Occurs during construction. Subclasses should override this method and call addTrait for each trait of their own.

Event Detail

containerChange

Event
Event Object Type: org.osmf.events.ContainerChangeEvent
property ContainerChangeEvent.type = org.osmf.events.ContainerChangeEvent.CONTAINER_CHANGE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when the element's container property changed.

The ContainerChangeEvent.CONTAINER_CHANGE constant defines the value of the type property of the event object for a containerChange event.

mediaError

Event  
Event Object Type: org.osmf.events.MediaErrorEvent
property MediaErrorEvent.type = org.osmf.events.MediaErrorEvent.MEDIA_ERROR

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when an error which impacts the operation of the media element occurs.

The MediaErrorEvent.MEDIA_ERROR constant defines the value of the type property of the event object for a mediaError event.

mediaInfo

Event  
Event Object Type: org.osmf.events.MediaErrorEvent
property MediaErrorEvent.type = org.osmf.events.MediaErrorEvent.MEDIA_INFO

Language Version: ActionScript 3.0
Product Version: OSMF 2.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a info which impacts the operation of the media element is available. MEDIA_INFO events are non-fatal.

metadataAdd

Event  
Event Object Type: org.osmf.events.MediaElementEvent
property MediaElementEvent.type = org.osmf.events.MediaElementEvent.METADATA_ADD

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a Metadata object has been added to this media element.

The MediaElementEvent.METADATA_ADD constant defines the value of the type property of the event object for a metadataAdd event.

metadataRemove

Event  
Event Object Type: org.osmf.events.MediaElementEvent
property MediaElementEvent.type = org.osmf.events.MediaElementEvent.METADATA_REMOVE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a Metadata object has been removed from this media element.

The MediaElementEvent.METADATA_REMOVE constant defines the value of the type property of the event object for a metadataRemove event.

traitAdd

Event  
Event Object Type: org.osmf.events.MediaElementEvent
property MediaElementEvent.type = org.osmf.events.MediaElementEvent.TRAIT_ADD

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a trait is added to the media element.

The MediaElementEvent.TRAIT_ADD constant defines the value of the type property of the event object for a traitAdd event.

traitRemove

Event  
Event Object Type: org.osmf.events.MediaElementEvent
property MediaElementEvent.type = org.osmf.events.MediaElementEvent.TRAIT_REMOVE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a trait is removed from the media element.

The MediaElementEvent.TRAIT_REMOVE constant defines the value of the type property of the event object for a traitRemove event.