org.osmf.media

# DefaultMediaFactory - AS3 OSMF

Package | org.osmf.media
Class | public class DefaultMediaFactory
Inheritance | DefaultMediaFactory MediaFactory EventDispatcher Object

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

DefaultMediaFactory is the default implementation of MediaFactory.

The default media factory can construct media elements of the following types:

- VideoElement, using either:
  - NetLoader (streaming or progressive)
  - RTMPDynamicStreamingNetLoader (MBR streaming)
  - HTTPStreamingNetLoader (HTTP streaming), if the CONFIG::FLASH_10_1 compiler flag is set to true
  - F4MLoader (Flash Media Manifest files)
  - DVRCastNetLoader (DVRCast)
- SoundElement, using either:
  - SoundLoader (progressive)
  - NetLoader (streaming)
- ImageElement
- SWFElement

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
|  | numItems : int [read-only] The number of MediaFactoryItems managed by the factory. | MediaFactory

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | DefaultMediaFactory() Constructor. | DefaultMediaFactory
|  | 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
|  | addItem(item:MediaFactoryItem):void Adds the specified MediaFactoryItem to the factory. | MediaFactory
|  | createMediaElement(resource:MediaResourceBase):MediaElement Returns a MediaElement that can be created based on the specified MediaResourceBase. | MediaFactory
|  | dispatchEvent(event:Event):Boolean Dispatches an event into the event flow. | EventDispatcher
|  | getItemAt(index:int):MediaFactoryItem Gets the MediaFactoryItem at the specified index. | MediaFactory
|  | getItemById(id:String):MediaFactoryItem Returns the MediaFactoryItem with the specified ID or null if the specified MediaFactoryItem does not exist in this factory. | MediaFactory
|  | 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
|  | loadPlugin(resource:MediaResourceBase):void Load a plugin identified by the specified resource. | MediaFactory
|  | 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
|  | removeItem(item:MediaFactoryItem):void Removes the specified MediaFactoryItem from the factory. | MediaFactory
|  | 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

Protected Methods
Hide Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | resolveItems(resource:MediaResourceBase, items:Vector.<MediaFactoryItem>):MediaFactoryItem Returns the most appropriate MediaFactoryItem for the specified resource out of the MediaFactoryItems in the specified list. | MediaFactory

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
|  | mediaElementCreate | Dispatched when the MediaFactory has created a MediaElement. | MediaFactory
|  | pluginLoad | Dispatched when the MediaFactory has successfully loaded a plugin. | MediaFactory
|  | pluginLoadError | Dispatched when the MediaFactory has failed to load a plugin due to an error. | MediaFactory

Constructor Detail

### DefaultMediaFactory

()
Constructor

`public function DefaultMediaFactory()`

Language Version: | ActionScript 3.0

Product Version: | OSMF 1.0

Runtime Versions: | Flash Player 10, AIR 1.5

Constructor.

Examples How to use this example
DefaultMediaFactoryExample.as
This example demonstrates how to manually use the DefaultMediaFactory class to instantiate a video element.
Copy

    package org.osmf.media
    {
        import flash.display.Sprite;

        import org.osmf.containers.MediaContainer;

        public class DefaultMediaFactoryExample extends Sprite
        {
            public function DefaultMediaFactoryExample()
            {
                // Construct a default media factory:
                var factory:DefaultMediaFactory = new DefaultMediaFactory();

                // Request the factory to create a media element that matches the passed URL:
                var media:MediaElement = factory.createMediaElement(new URLResource("http://mediapm.edgesuite.net/strobe/content/test/AFaerysTale_sylviaApostol_640_500_short.flv"));

                // Add a media container, and player to have the constructed VideoElement
                // play back:
                var mediaContainer:MediaContainer = new MediaContainer();
                addChild(mediaContainer);
                mediaContainer.width = 640;
                mediaContainer.height = 500;
                mediaContainer.addMediaElement(media);
                new MediaPlayer(media);
            }

        }
    }

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