套件 | org.osmf.media |
類別 | public class MediaFactory |
繼承 | MediaFactory EventDispatcher Object |
子類別 | DefaultMediaFactory |
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
The factory operation takes a MediaResourceBase as input and produces a MediaElement as output.
The MediaFactory maintains a list of MediaFactoryItem objects, each of which encapsulates all the information necessary to create a specific MediaElement. The MediaFactory relies on the canHandleResourceFunction method of each MediaFactoryItem to find a MediaFactoryItem object that can handle the specified MediaResourceBase.
The factory interface also exposes methods for querying for specific MediaFactoryItem objects, and for loading plugins (which hold MediaFactoryItem objects).
相關 API 元素
屬性 | 定義自 | ||
---|---|---|---|
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
numItems : int [唯讀]
The number of MediaFactoryItems managed by the factory. | MediaFactory |
方法 | 定義自 | ||
---|---|---|---|
Constructor. | MediaFactory | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
Adds the specified MediaFactoryItem to the factory. | MediaFactory | ||
Returns a MediaElement that can be created based on the specified
MediaResourceBase. | MediaFactory | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
Gets the MediaFactoryItem at the specified index. | MediaFactory | ||
Returns the MediaFactoryItem with the specified ID or null if the
specified MediaFactoryItem does not exist in this factory. | MediaFactory | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
Load a plugin identified by the specified resource. | MediaFactory | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
Removes the specified MediaFactoryItem from the factory. | MediaFactory | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
會傳回指定之物件的字串形式。 | Object | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
方法 | 定義自 | ||
---|---|---|---|
Returns the most appropriate MediaFactoryItem for the specified resource
out of the MediaFactoryItems in the specified list. | MediaFactory |
事件 | 摘要 | 定義自 | ||
---|---|---|---|---|
[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。 | EventDispatcher | |||
[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。 | EventDispatcher | |||
Dispatched when the MediaFactory has created a MediaElement. | MediaFactory | |||
Dispatched when the MediaFactory has successfully loaded a plugin. | MediaFactory | |||
Dispatched when the MediaFactory has failed to load a plugin due to an error. | MediaFactory |
numItems | 屬性 |
MediaFactory | () | 建構函式 |
public function MediaFactory()
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Constructor.
addItem | () | 方法 |
public function addItem(item:MediaFactoryItem):void
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Adds the specified MediaFactoryItem to the factory. After the MediaFactoryItem has been added, for any MediaResourceBase that this MediaFactoryItem can handle, the factory will be able to create the corresponding media element. If a MediaFactoryItem with the same ID already exists in this factory, the new MediaFactoryItem object replaces it.
參數
item:MediaFactoryItem — The MediaFactoryItem to add.
|
擲回值
ArgumentError — If the argument is null or if the argument
has a null ID field.
|
createMediaElement | () | 方法 |
public function createMediaElement(resource:MediaResourceBase):MediaElement
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Returns a MediaElement that can be created based on the specified MediaResourceBase.
Returns null
if the factory cannot
find a MediaFactoryItem object
capable of creating such a MediaElement in this factory.
參數
resource:MediaResourceBase — The MediaResourceBase for which a corresponding
MediaElement should be created.
|
MediaElement — The MediaElement that was created or null if no such
MediaElement could be created from the resource.
|
getItemAt | () | 方法 |
public function getItemAt(index:int):MediaFactoryItem
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Gets the MediaFactoryItem at the specified index.
參數
index:int — The index in the list from which to retrieve the MediaFactoryItem.
|
MediaFactoryItem — The MediaFactoryItem at that index or null if there is none.
|
getItemById | () | 方法 |
public function getItemById(id:String):MediaFactoryItem
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Returns the MediaFactoryItem with the specified ID or null
if the
specified MediaFactoryItem does not exist in this factory.
參數
id:String — ID of the MediaFactoryItem to retrieve.
|
MediaFactoryItem — The MediaFactoryItem with the specified ID or null if the specified
MediaFactoryItem does not exist in this factory.
|
loadPlugin | () | 方法 |
public function loadPlugin(resource:MediaResourceBase):void
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Load a plugin identified by the specified resource. The MediaFactory will not reload the plugin if it has already been loaded. Upon successful loading, the MediaFactoryItems within the plugin's PluginInfo property will be added to this MediaFactory, and a MediaFactoryEvent.PLUGIN_LOAD event will be dispatched. OtherwiseIf the load fails, a MediaFactoryEvent.PLUGIN_LOAD_ERROR event will be dispatched.
參數
resource:MediaResourceBase — MediaResourceBase representing the plugin. For remote (dynamic)
plugins, use an URLResource pointing to the remote SWF to load. For local
(static) plugins, use a PluginInfoResource.
|
擲回值
ArgumentError — If resource is null or resource is neither an URLResource
nor a PluginInfoResource.
|
removeItem | () | 方法 |
public function removeItem(item:MediaFactoryItem):void
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Removes the specified MediaFactoryItem from the factory. If no such MediaFactoryItem exists in this factory, does nothing.
參數
item:MediaFactoryItem — The MediaFactoryItem to remove.
|
擲回值
ArgumentError — If the argument is null or if the argument
has a null ID field.
|
resolveItems | () | 方法 |
protected function resolveItems(resource:MediaResourceBase, items:Vector.<MediaFactoryItem>):MediaFactoryItem
Returns the most appropriate MediaFactoryItem for the specified resource
out of the MediaFactoryItems in the specified list.
This method is invoked when createMediaElement
is invoked
with a resource that more than one MediaFactoryItem can handle. Subclasses
can override to select the most appropriate one.
The default behavior is to select the first item which is not "native" to
the framework, under the theory that plugins ought to take precedence over
core media types. It makes this decision based on the presence or absence
of an id value which starts with "org.osmf".
參數
resource:MediaResourceBase | |
items:Vector.<MediaFactoryItem> |
MediaFactoryItem |
mediaElementCreate | 事件 |
org.osmf.events.MediaFactoryEvent
屬性 MediaFactoryEvent.type =
org.osmf.events.MediaFactoryEvent.MEDIA_ELEMENT_CREATE
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Dispatched when the MediaFactory has created a MediaElement.
The MediaFactoryEvent.MEDIA_ELEMENT_CREATE constant defines the value of the type property of the event object for a mediaElementCreate event.pluginLoad | 事件 |
org.osmf.events.MediaFactoryEvent
屬性 MediaFactoryEvent.type =
org.osmf.events.MediaFactoryEvent.PLUGIN_LOAD
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Dispatched when the MediaFactory has successfully loaded a plugin.
The MediaFactoryEvent.PLUGIN_LOAD constant defines the value of the type property of the event object for a pluginLoad event.pluginLoadError | 事件 |
org.osmf.events.MediaFactoryEvent
屬性 MediaFactoryEvent.type =
org.osmf.events.MediaFactoryEvent.PLUGIN_LOAD_ERROR
語言版本: | ActionScript 3.0 |
產品版本: | OSMF 1.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Dispatched when the MediaFactory has failed to load a plugin due to an error.
The MediaFactoryEvent.PLUGIN_LOAD_ERROR constant defines the value of the type property of the event object for a pluginLoadError event.package org.osmf.media { import flash.display.Sprite; import org.osmf.events.MediaFactoryEvent; public class MediaFactoryExample extends Sprite { public function MediaFactoryExample() { // Construct a media factory, and listen to its plug-in related events: var factory:MediaFactory = new MediaFactory(); factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD, onPluginLoaded); factory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD_ERROR, onPluginLoadError); // Instruct the factory to load the plug-in at the given url: factory.loadPlugin(new URLResource("http://myinvalidurl.com/foo.swf")); } private function onPluginLoaded(event:MediaFactoryEvent):void { // Use the factory to create a media-element related to the plugin: var factory:MediaFactory = event.target as MediaFactory; factory.createMediaElement(new URLResource("http://myinvalidurl.com/content")); } private function onPluginLoadError(event:MediaFactoryEvent):void { // Handle plug-in loading failure: trace("Plugin failed to load."); } } }
Tue Jun 12 2018, 03:47 PM Z