mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
+83
@@ -0,0 +1,83 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import org.osmf.elements.SWFLoader;
|
||||
import org.osmf.elements.loaderClasses.LoaderLoadTrait;
|
||||
import org.osmf.events.LoaderEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.PluginInfo;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
internal class DynamicPluginLoader extends PluginLoader
|
||||
{
|
||||
|
||||
private static const PLUGININFO_PROPERTY_NAME:String = "pluginInfo";
|
||||
|
||||
public function DynamicPluginLoader(mediaFactory:MediaFactory, minimumSupportedFrameworkVersion:String)
|
||||
{
|
||||
super(mediaFactory,minimumSupportedFrameworkVersion);
|
||||
}
|
||||
|
||||
override public function canHandleResource(resource:MediaResourceBase) : Boolean
|
||||
{
|
||||
return new SWFLoader().canHandleResource(resource);
|
||||
}
|
||||
|
||||
override protected function executeLoad(loadTrait:LoadTrait) : void
|
||||
{
|
||||
var swfLoader:SWFLoader = null;
|
||||
var loaderLoadTrait:LoaderLoadTrait = null;
|
||||
var onSWFLoaderStateChange:Function = null;
|
||||
var onLoadError:Function = null;
|
||||
onSWFLoaderStateChange = function(event:LoaderEvent):void
|
||||
{
|
||||
var root:DisplayObject = null;
|
||||
var pluginInfo:PluginInfo = null;
|
||||
if(event.newState == LoadState.READY)
|
||||
{
|
||||
swfLoader.removeEventListener(LoaderEvent.LOAD_STATE_CHANGE,onSWFLoaderStateChange);
|
||||
loaderLoadTrait.removeEventListener(MediaErrorEvent.MEDIA_ERROR,onLoadError);
|
||||
root = loaderLoadTrait.loader.content;
|
||||
pluginInfo = root[PLUGININFO_PROPERTY_NAME] as PluginInfo;
|
||||
loadFromPluginInfo(loadTrait,pluginInfo,loaderLoadTrait.loader);
|
||||
}
|
||||
else if(event.newState == LoadState.LOAD_ERROR)
|
||||
{
|
||||
swfLoader.removeEventListener(LoaderEvent.LOAD_STATE_CHANGE,onSWFLoaderStateChange);
|
||||
updateLoadTrait(loadTrait,event.newState);
|
||||
}
|
||||
};
|
||||
onLoadError = function(event:MediaErrorEvent):void
|
||||
{
|
||||
loaderLoadTrait.removeEventListener(MediaErrorEvent.MEDIA_ERROR,onLoadError);
|
||||
loadTrait.dispatchEvent(event.clone());
|
||||
};
|
||||
updateLoadTrait(loadTrait,LoadState.LOADING);
|
||||
swfLoader = new SWFLoader(true);
|
||||
swfLoader.validateLoadedContentFunction = this.validateLoadedContent;
|
||||
swfLoader.addEventListener(LoaderEvent.LOAD_STATE_CHANGE,onSWFLoaderStateChange);
|
||||
loaderLoadTrait = new LoaderLoadTrait(swfLoader,loadTrait.resource);
|
||||
loaderLoadTrait.addEventListener(MediaErrorEvent.MEDIA_ERROR,onLoadError);
|
||||
swfLoader.load(loaderLoadTrait);
|
||||
}
|
||||
|
||||
override protected function executeUnload(loadTrait:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.UNLOADING);
|
||||
var pluginLoadTrait:PluginLoadTrait = loadTrait as PluginLoadTrait;
|
||||
unloadFromPluginInfo(pluginLoadTrait.pluginInfo);
|
||||
pluginLoadTrait.loader.unloadAndStop();
|
||||
updateLoadTrait(loadTrait,LoadState.UNINITIALIZED);
|
||||
}
|
||||
|
||||
private function validateLoadedContent(displayObject:DisplayObject) : Boolean
|
||||
{
|
||||
var pluginInfo:Object = displayObject.hasOwnProperty(PLUGININFO_PROPERTY_NAME) ? displayObject[PLUGININFO_PROPERTY_NAME] : null;
|
||||
return pluginInfo != null ? isPluginCompatible(pluginInfo) : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import org.osmf.media.LoadableElementBase;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
internal class PluginElement extends LoadableElementBase
|
||||
{
|
||||
|
||||
public function PluginElement(loader:PluginLoader, resource:MediaResourceBase = null)
|
||||
{
|
||||
super(resource,loader);
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(resource:MediaResourceBase, loader:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new PluginLoadTrait(loader,resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import org.osmf.media.MediaElement;
|
||||
|
||||
internal class PluginEntry
|
||||
{
|
||||
|
||||
private var _pluginElement:MediaElement;
|
||||
|
||||
private var _state:PluginLoadingState;
|
||||
|
||||
public function PluginEntry(pluginElement:MediaElement, state:PluginLoadingState)
|
||||
{
|
||||
super();
|
||||
this._pluginElement = pluginElement;
|
||||
this._state = state;
|
||||
}
|
||||
|
||||
public function get pluginElement() : MediaElement
|
||||
{
|
||||
return this._pluginElement;
|
||||
}
|
||||
|
||||
public function get state() : PluginLoadingState
|
||||
{
|
||||
return this._state;
|
||||
}
|
||||
|
||||
public function set state(value:PluginLoadingState) : void
|
||||
{
|
||||
this._state = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.PluginInfo;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
[ExcludeClass]
|
||||
internal class PluginLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _pluginInfo:PluginInfo;
|
||||
|
||||
private var _loader:Loader;
|
||||
|
||||
public function PluginLoadTrait(loader:LoaderBase, resource:MediaResourceBase)
|
||||
{
|
||||
super(loader,resource);
|
||||
}
|
||||
|
||||
public function get pluginInfo() : PluginInfo
|
||||
{
|
||||
return this._pluginInfo;
|
||||
}
|
||||
|
||||
public function set pluginInfo(value:PluginInfo) : void
|
||||
{
|
||||
this._pluginInfo = value;
|
||||
}
|
||||
|
||||
public function get loader() : Loader
|
||||
{
|
||||
return this._loader;
|
||||
}
|
||||
|
||||
public function set loader(value:Loader) : void
|
||||
{
|
||||
this._loader = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaFactoryItem;
|
||||
import org.osmf.media.PluginInfo;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.Version;
|
||||
|
||||
internal class PluginLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private static const FRAMEWORK_VERSION_PROPERTY_NAME:String = "frameworkVersion";
|
||||
|
||||
private static const IS_FRAMEWORK_VERSION_SUPPORTED_PROPERTY_NAME:String = "isFrameworkVersionSupported";
|
||||
|
||||
private var minimumSupportedFrameworkVersion:String;
|
||||
|
||||
private var mediaFactory:MediaFactory;
|
||||
|
||||
public function PluginLoader(mediaFactory:MediaFactory, minimumSupportedFrameworkVersion:String)
|
||||
{
|
||||
super();
|
||||
this.mediaFactory = mediaFactory;
|
||||
this.minimumSupportedFrameworkVersion = minimumSupportedFrameworkVersion;
|
||||
}
|
||||
|
||||
protected function unloadFromPluginInfo(pluginInfo:PluginInfo) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var item:MediaFactoryItem = null;
|
||||
var actualItem:MediaFactoryItem = null;
|
||||
if(pluginInfo != null)
|
||||
{
|
||||
for(i = 0; i < pluginInfo.numMediaFactoryItems; i++)
|
||||
{
|
||||
item = pluginInfo.getMediaFactoryItemAt(i);
|
||||
actualItem = this.mediaFactory.getItemById(item.id);
|
||||
if(actualItem != null)
|
||||
{
|
||||
this.mediaFactory.removeItem(actualItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadFromPluginInfo(loadTrait:LoadTrait, pluginInfo:PluginInfo, loader:Loader = null) : void
|
||||
{
|
||||
var passedMediaFactory:MediaFactory = null;
|
||||
var i:int = 0;
|
||||
var pluginLoadTrait:PluginLoadTrait = null;
|
||||
var item:MediaFactoryItem = null;
|
||||
var invalidImplementation:Boolean = false;
|
||||
if(pluginInfo != null)
|
||||
{
|
||||
if(this.isPluginCompatible(pluginInfo))
|
||||
{
|
||||
try
|
||||
{
|
||||
passedMediaFactory = loadTrait.resource.getMetadataValue(PluginInfo.PLUGIN_MEDIAFACTORY_NAMESPACE) as MediaFactory;
|
||||
if(passedMediaFactory == null)
|
||||
{
|
||||
loadTrait.resource.addMetadataValue(PluginInfo.PLUGIN_MEDIAFACTORY_NAMESPACE,this.mediaFactory);
|
||||
}
|
||||
pluginInfo.initializePlugin(loadTrait.resource);
|
||||
for(i = 0; i < pluginInfo.numMediaFactoryItems; i++)
|
||||
{
|
||||
item = pluginInfo.getMediaFactoryItemAt(i);
|
||||
if(item == null)
|
||||
{
|
||||
throw new RangeError();
|
||||
}
|
||||
this.mediaFactory.addItem(item);
|
||||
}
|
||||
pluginLoadTrait = loadTrait as PluginLoadTrait;
|
||||
pluginLoadTrait.pluginInfo = pluginInfo;
|
||||
pluginLoadTrait.loader = loader;
|
||||
updateLoadTrait(pluginLoadTrait,LoadState.READY);
|
||||
}
|
||||
catch(error:RangeError)
|
||||
{
|
||||
invalidImplementation = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.PLUGIN_VERSION_INVALID)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidImplementation = true;
|
||||
}
|
||||
if(invalidImplementation)
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.PLUGIN_IMPLEMENTATION_INVALID)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function isPluginCompatible(pluginInfo:Object) : Boolean
|
||||
{
|
||||
var versionSupportedFunction:Function = null;
|
||||
var isCompatible:Boolean = false;
|
||||
var version:String = pluginInfo.hasOwnProperty(FRAMEWORK_VERSION_PROPERTY_NAME) ? pluginInfo[FRAMEWORK_VERSION_PROPERTY_NAME] : null;
|
||||
var isSupported:Boolean = this.isPluginVersionSupported(version);
|
||||
if(isSupported)
|
||||
{
|
||||
versionSupportedFunction = pluginInfo.hasOwnProperty(IS_FRAMEWORK_VERSION_SUPPORTED_PROPERTY_NAME) ? pluginInfo[IS_FRAMEWORK_VERSION_SUPPORTED_PROPERTY_NAME] as Function : null;
|
||||
if(versionSupportedFunction != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
isCompatible = versionSupportedFunction(Version.version);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return isCompatible;
|
||||
}
|
||||
|
||||
private function isPluginVersionSupported(pluginVersion:String) : Boolean
|
||||
{
|
||||
if(pluginVersion == null || pluginVersion.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var minVersion:Object = VersionUtils.parseVersionString(this.minimumSupportedFrameworkVersion);
|
||||
var pVersion:Object = VersionUtils.parseVersionString(pluginVersion);
|
||||
return pVersion.major > minVersion.major || pVersion.major == minVersion.major && pVersion.minor >= minVersion.minor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
internal class PluginLoadingState
|
||||
{
|
||||
|
||||
public static const LOADING:PluginLoadingState = new PluginLoadingState("Loading");
|
||||
|
||||
public static const LOADED:PluginLoadingState = new PluginLoadingState("Loaded");
|
||||
|
||||
private var _state:String;
|
||||
|
||||
public function PluginLoadingState(state:String)
|
||||
{
|
||||
super();
|
||||
this._state = state;
|
||||
}
|
||||
|
||||
public function get state() : String
|
||||
{
|
||||
return this._state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.events.MediaFactoryEvent;
|
||||
import org.osmf.events.PluginManagerEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaFactoryItem;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.PluginInfoResource;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.Version;
|
||||
|
||||
[Event(name="pluginLoadError",type="org.osmf.events.PluginManagerEvent")]
|
||||
[Event(name="pluginLoad",type="org.osmf.events.PluginManagerEvent")]
|
||||
[ExcludeClass]
|
||||
public class PluginManager extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const STATIC_PLUGIN_MEDIA_INFO_ID:String = "org.osmf.plugins.StaticPluginLoader";
|
||||
|
||||
private static const DYNAMIC_PLUGIN_MEDIA_INFO_ID:String = "org.osmf.plugins.DynamicPluginLoader";
|
||||
|
||||
private var _mediaFactory:MediaFactory;
|
||||
|
||||
private var _pluginFactory:MediaFactory;
|
||||
|
||||
private var _pluginMap:Dictionary;
|
||||
|
||||
private var _pluginList:Vector.<PluginEntry>;
|
||||
|
||||
private var notificationFunctions:Vector.<Function>;
|
||||
|
||||
private var createdElements:Dictionary;
|
||||
|
||||
private var minimumSupportedFrameworkVersion:String;
|
||||
|
||||
private var staticPluginLoader:StaticPluginLoader;
|
||||
|
||||
private var dynamicPluginLoader:DynamicPluginLoader;
|
||||
|
||||
public function PluginManager(mediaFactory:MediaFactory)
|
||||
{
|
||||
super();
|
||||
this._mediaFactory = mediaFactory;
|
||||
this._mediaFactory.addEventListener(MediaFactoryEvent.MEDIA_ELEMENT_CREATE,this.onMediaElementCreate);
|
||||
this.minimumSupportedFrameworkVersion = Version.lastAPICompatibleVersion;
|
||||
this.initPluginFactory();
|
||||
this._pluginMap = new Dictionary();
|
||||
this._pluginList = new Vector.<PluginEntry>();
|
||||
}
|
||||
|
||||
public function loadPlugin(resource:MediaResourceBase) : void
|
||||
{
|
||||
var identifier:Object = null;
|
||||
var pluginEntry:PluginEntry = null;
|
||||
var onLoadStateChange:Function = null;
|
||||
var onMediaError:Function = null;
|
||||
var pluginElement:MediaElement = null;
|
||||
var loadTrait:LoadTrait = null;
|
||||
onLoadStateChange = function(event:LoadEvent):void
|
||||
{
|
||||
var pluginLoadTrait:PluginLoadTrait = null;
|
||||
if(event.loadState == LoadState.READY)
|
||||
{
|
||||
pluginEntry.state = PluginLoadingState.LOADED;
|
||||
_pluginList.push(pluginEntry);
|
||||
pluginLoadTrait = pluginElement.getTrait(MediaTraitType.LOAD) as PluginLoadTrait;
|
||||
if(pluginLoadTrait.pluginInfo.mediaElementCreationNotificationFunction != null)
|
||||
{
|
||||
invokeMediaElementCreationNotificationForCreatedMediaElements(pluginLoadTrait.pluginInfo.mediaElementCreationNotificationFunction);
|
||||
if(notificationFunctions == null)
|
||||
{
|
||||
notificationFunctions = new Vector.<Function>();
|
||||
}
|
||||
notificationFunctions.push(pluginLoadTrait.pluginInfo.mediaElementCreationNotificationFunction);
|
||||
}
|
||||
dispatchEvent(new PluginManagerEvent(PluginManagerEvent.PLUGIN_LOAD,false,false,resource));
|
||||
}
|
||||
else if(event.loadState == LoadState.LOAD_ERROR)
|
||||
{
|
||||
delete _pluginMap[identifier];
|
||||
dispatchEvent(new PluginManagerEvent(PluginManagerEvent.PLUGIN_LOAD_ERROR,false,false,resource));
|
||||
}
|
||||
};
|
||||
onMediaError = function(event:MediaErrorEvent):void
|
||||
{
|
||||
dispatchEvent(event.clone());
|
||||
};
|
||||
if(resource == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
identifier = this.getPluginIdentifier(resource);
|
||||
pluginEntry = this._pluginMap[identifier] as PluginEntry;
|
||||
if(pluginEntry != null)
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent(PluginManagerEvent.PLUGIN_LOAD,false,false,resource));
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginElement = this._pluginFactory.createMediaElement(resource);
|
||||
if(pluginElement != null)
|
||||
{
|
||||
pluginEntry = new PluginEntry(pluginElement,PluginLoadingState.LOADING);
|
||||
this._pluginMap[identifier] = pluginEntry;
|
||||
loadTrait = pluginElement.getTrait(MediaTraitType.LOAD) as LoadTrait;
|
||||
if(loadTrait != null)
|
||||
{
|
||||
loadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE,onLoadStateChange);
|
||||
loadTrait.addEventListener(MediaErrorEvent.MEDIA_ERROR,onMediaError);
|
||||
loadTrait.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent(PluginManagerEvent.PLUGIN_LOAD_ERROR,false,false,resource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent(PluginManagerEvent.PLUGIN_LOAD_ERROR,false,false,resource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get mediaFactory() : MediaFactory
|
||||
{
|
||||
return this._mediaFactory;
|
||||
}
|
||||
|
||||
private function getPluginIdentifier(resource:MediaResourceBase) : Object
|
||||
{
|
||||
var identifier:Object = null;
|
||||
if(resource is URLResource)
|
||||
{
|
||||
identifier = (resource as URLResource).url;
|
||||
}
|
||||
else if(resource is PluginInfoResource)
|
||||
{
|
||||
identifier = (resource as PluginInfoResource).pluginInfo;
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
|
||||
private function initPluginFactory() : void
|
||||
{
|
||||
this._pluginFactory = new MediaFactory();
|
||||
this.staticPluginLoader = new StaticPluginLoader(this.mediaFactory,this.minimumSupportedFrameworkVersion);
|
||||
this.dynamicPluginLoader = new DynamicPluginLoader(this.mediaFactory,this.minimumSupportedFrameworkVersion);
|
||||
var staticPluginItem:MediaFactoryItem = new MediaFactoryItem(STATIC_PLUGIN_MEDIA_INFO_ID,this.staticPluginLoader.canHandleResource,this.createStaticPluginElement);
|
||||
this._pluginFactory.addItem(staticPluginItem);
|
||||
var dynamicPluginItem:MediaFactoryItem = new MediaFactoryItem(DYNAMIC_PLUGIN_MEDIA_INFO_ID,this.dynamicPluginLoader.canHandleResource,this.createDynamicPluginElement);
|
||||
this._pluginFactory.addItem(dynamicPluginItem);
|
||||
}
|
||||
|
||||
private function createStaticPluginElement() : MediaElement
|
||||
{
|
||||
return new PluginElement(this.staticPluginLoader);
|
||||
}
|
||||
|
||||
private function createDynamicPluginElement() : MediaElement
|
||||
{
|
||||
return new PluginElement(this.dynamicPluginLoader);
|
||||
}
|
||||
|
||||
private function onMediaElementCreate(event:MediaFactoryEvent) : void
|
||||
{
|
||||
this.invokeMediaElementCreationNotifications(event.mediaElement);
|
||||
if(this.createdElements == null)
|
||||
{
|
||||
this.createdElements = new Dictionary(true);
|
||||
}
|
||||
this.createdElements[event.mediaElement] = true;
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotifications(mediaElement:MediaElement) : void
|
||||
{
|
||||
var func:Function = null;
|
||||
for each(func in this.notificationFunctions)
|
||||
{
|
||||
this.invokeMediaElementCreationNotificationFunction(func,mediaElement);
|
||||
}
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotificationFunction(func:Function, mediaElement:MediaElement) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
func.call(null,mediaElement);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotificationForCreatedMediaElements(func:Function) : void
|
||||
{
|
||||
var elem:Object = null;
|
||||
for(elem in this.createdElements)
|
||||
{
|
||||
this.invokeMediaElementCreationNotificationFunction(func,elem as MediaElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.PluginInfo;
|
||||
import org.osmf.media.PluginInfoResource;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
internal class StaticPluginLoader extends PluginLoader
|
||||
{
|
||||
|
||||
public function StaticPluginLoader(mediaFactory:MediaFactory, minimumSupportedFrameworkVersion:String)
|
||||
{
|
||||
super(mediaFactory,minimumSupportedFrameworkVersion);
|
||||
}
|
||||
|
||||
override public function canHandleResource(resource:MediaResourceBase) : Boolean
|
||||
{
|
||||
return resource is PluginInfoResource;
|
||||
}
|
||||
|
||||
override protected function executeLoad(loadTrait:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.LOADING);
|
||||
var classResource:PluginInfoResource = loadTrait.resource as PluginInfoResource;
|
||||
var pluginInfo:PluginInfo = classResource.pluginInfo;
|
||||
loadFromPluginInfo(loadTrait,pluginInfo);
|
||||
}
|
||||
|
||||
override protected function executeUnload(loadTrait:LoadTrait) : void
|
||||
{
|
||||
var pluginLoadTrait:PluginLoadTrait = loadTrait as PluginLoadTrait;
|
||||
var pluginInfo:PluginInfo = pluginLoadTrait.pluginInfo;
|
||||
updateLoadTrait(loadTrait,LoadState.UNLOADING);
|
||||
unloadFromPluginInfo(pluginInfo);
|
||||
updateLoadTrait(loadTrait,LoadState.UNINITIALIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
[ExcludeClass]
|
||||
public class VersionUtils
|
||||
{
|
||||
|
||||
public function VersionUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function parseVersionString(version:String) : Object
|
||||
{
|
||||
var versionInfo:Array = version.split(".");
|
||||
var major:int = 0;
|
||||
var minor:int = 0;
|
||||
if(versionInfo.length >= 1)
|
||||
{
|
||||
major = parseInt(versionInfo[0]);
|
||||
}
|
||||
if(versionInfo.length >= 2)
|
||||
{
|
||||
minor = parseInt(versionInfo[1]);
|
||||
if(minor < 10)
|
||||
{
|
||||
minor *= 10;
|
||||
}
|
||||
}
|
||||
return {
|
||||
"major":major,
|
||||
"minor":minor
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user