mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01: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
@@ -0,0 +1,99 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.elements.AudioElement;
|
||||
import org.osmf.elements.F4MElement;
|
||||
import org.osmf.elements.F4MLoader;
|
||||
import org.osmf.elements.ImageElement;
|
||||
import org.osmf.elements.ImageLoader;
|
||||
import org.osmf.elements.SWFElement;
|
||||
import org.osmf.elements.SWFLoader;
|
||||
import org.osmf.elements.SoundLoader;
|
||||
import org.osmf.elements.VideoElement;
|
||||
import org.osmf.net.MulticastNetLoader;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.dvr.DVRCastNetLoader;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingNetLoader;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
|
||||
public class DefaultMediaFactory extends MediaFactory
|
||||
{
|
||||
|
||||
private var rtmpStreamingNetLoader:RTMPDynamicStreamingNetLoader;
|
||||
|
||||
private var f4mLoader:F4MLoader;
|
||||
|
||||
private var dvrCastLoader:DVRCastNetLoader;
|
||||
|
||||
private var netLoader:NetLoader;
|
||||
|
||||
private var imageLoader:ImageLoader;
|
||||
|
||||
private var swfLoader:SWFLoader;
|
||||
|
||||
private var soundLoader:SoundLoader;
|
||||
|
||||
private var httpStreamingNetLoader:HTTPStreamingNetLoader;
|
||||
|
||||
private var multicastLoader:MulticastNetLoader;
|
||||
|
||||
public function DefaultMediaFactory()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
f4mLoader = new F4MLoader(this);
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.f4m",f4mLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new F4MElement(null,f4mLoader);
|
||||
}));
|
||||
dvrCastLoader = new DVRCastNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.dvr.dvrcast",dvrCastLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,dvrCastLoader);
|
||||
}));
|
||||
httpStreamingNetLoader = new HTTPStreamingNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.httpstreaming",httpStreamingNetLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,httpStreamingNetLoader);
|
||||
}));
|
||||
multicastLoader = new MulticastNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.rtmfp.multicast",multicastLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,multicastLoader);
|
||||
}));
|
||||
rtmpStreamingNetLoader = new RTMPDynamicStreamingNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.rtmpdynamicStreaming",rtmpStreamingNetLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,rtmpStreamingNetLoader);
|
||||
}));
|
||||
netLoader = new NetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video",netLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,netLoader);
|
||||
}));
|
||||
soundLoader = new SoundLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.audio",soundLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new AudioElement(null,soundLoader);
|
||||
}));
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.audio.streaming",netLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new AudioElement(null,netLoader);
|
||||
}));
|
||||
imageLoader = new ImageLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.image",imageLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new ImageElement(null,imageLoader);
|
||||
}));
|
||||
swfLoader = new SWFLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.swf",swfLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new SWFElement(null,swfLoader);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class DefaultTraitResolver extends MediaTraitResolver
|
||||
{
|
||||
|
||||
private var defaultTrait:MediaTraitBase;
|
||||
|
||||
private var trait:MediaTraitBase;
|
||||
|
||||
public function DefaultTraitResolver(param1:String, param2:MediaTraitBase)
|
||||
{
|
||||
super(param1);
|
||||
if(param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param2.traitType != param1)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
this.defaultTrait = param2;
|
||||
setResolvedTrait(param2);
|
||||
}
|
||||
|
||||
override protected function processAddTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(trait == null)
|
||||
{
|
||||
setResolvedTrait(trait = param1);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processRemoveTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
var _loc2_:MediaTraitBase = null;
|
||||
if(param1 && param1 == trait)
|
||||
{
|
||||
_loc2_ = trait;
|
||||
trait = null;
|
||||
setResolvedTrait(defaultTrait);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoadableElementBase extends MediaElement
|
||||
{
|
||||
|
||||
private var _loader:LoaderBase;
|
||||
|
||||
public function LoadableElementBase(param1:MediaResourceBase = null, param2:LoaderBase = null)
|
||||
{
|
||||
super();
|
||||
_loader = param2;
|
||||
this.resource = param1;
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
super.resource = param1;
|
||||
updateLoadTrait();
|
||||
}
|
||||
|
||||
final protected function get loader() : LoaderBase
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
final protected function set loader(param1:LoaderBase) : void
|
||||
{
|
||||
_loader = param1;
|
||||
}
|
||||
|
||||
protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new LoadTrait(_loader,param1);
|
||||
}
|
||||
|
||||
protected function processLoadingState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processReadyState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processUnloadingState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function getLoaderForResource(param1:MediaResourceBase, param2:Vector.<LoaderBase>) : LoaderBase
|
||||
{
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc3_:LoaderBase = loader;
|
||||
if(param1 != null && (loader == null || loader.canHandleResource(param1) == false))
|
||||
{
|
||||
_loc5_ = false;
|
||||
for each(var _loc4_:LoaderBase in param2)
|
||||
{
|
||||
if(loader == null || loader != _loc4_)
|
||||
{
|
||||
if(_loc4_.canHandleResource(param1))
|
||||
{
|
||||
_loc3_ = _loc4_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc3_ == null && param2 != null)
|
||||
{
|
||||
_loc3_ = param2[param2.length - 1];
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function onLoadStateChange(param1:LoadEvent) : void
|
||||
{
|
||||
if(param1.loadState == "loading")
|
||||
{
|
||||
processLoadingState();
|
||||
}
|
||||
else if(param1.loadState == "ready")
|
||||
{
|
||||
processReadyState();
|
||||
}
|
||||
else if(param1.loadState == "unloading")
|
||||
{
|
||||
processUnloadingState();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateLoadTrait() : void
|
||||
{
|
||||
var _loc1_:LoadTrait = getTrait("load") as LoadTrait;
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
if(_loc1_.loadState == "ready")
|
||||
{
|
||||
_loc1_.unload();
|
||||
}
|
||||
_loc1_.removeEventListener("loadStateChange",onLoadStateChange);
|
||||
removeTrait("load");
|
||||
}
|
||||
if(loader != null)
|
||||
{
|
||||
_loc1_ = createLoadTrait(resource,loader);
|
||||
_loc1_.addEventListener("loadStateChange",onLoadStateChange,false,10);
|
||||
addTrait("load",_loc1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.containers.IMediaContainer;
|
||||
import org.osmf.events.ContainerChangeEvent;
|
||||
import org.osmf.events.MediaElementEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaElement extends EventDispatcher
|
||||
{
|
||||
|
||||
private var traits:Dictionary = new Dictionary();
|
||||
|
||||
private var traitResolvers:Dictionary = new Dictionary();
|
||||
|
||||
private var unresolvedTraits:Dictionary = new Dictionary();
|
||||
|
||||
private var _traitTypes:Vector.<String> = new Vector.<String>();
|
||||
|
||||
private var _resource:MediaResourceBase;
|
||||
|
||||
private var _metadata:Metadata;
|
||||
|
||||
private var _container:IMediaContainer;
|
||||
|
||||
public function MediaElement()
|
||||
{
|
||||
super();
|
||||
_metadata = createMetadata();
|
||||
_metadata.addEventListener("valueAdd",onMetadataValueAdd);
|
||||
_metadata.addEventListener("valueRemove",onMetadataValueRemove);
|
||||
_metadata.addEventListener("valueChange",onMetadataValueChange);
|
||||
setupTraitResolvers();
|
||||
setupTraits();
|
||||
addEventListener("containerChange",onContainerChange,false,1.7976931348623157e+308);
|
||||
}
|
||||
|
||||
public function get traitTypes() : Vector.<String>
|
||||
{
|
||||
return _traitTypes.concat();
|
||||
}
|
||||
|
||||
public function hasTrait(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return traits[param1] != null;
|
||||
}
|
||||
|
||||
public function getTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return traits[param1];
|
||||
}
|
||||
|
||||
public function get resource() : MediaResourceBase
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
_resource = param1;
|
||||
}
|
||||
|
||||
public function get container() : IMediaContainer
|
||||
{
|
||||
return _container;
|
||||
}
|
||||
|
||||
public function addMetadata(param1:String, param2:Metadata) : void
|
||||
{
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
this.metadata.addValue(param1,param2);
|
||||
}
|
||||
|
||||
public function removeMetadata(param1:String) : Metadata
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
return metadata.removeValue(param1) as Metadata;
|
||||
}
|
||||
|
||||
public function getMetadata(param1:String) : Metadata
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
return metadata.getValue(param1) as Metadata;
|
||||
}
|
||||
|
||||
public function get metadataNamespaceURLs() : Vector.<String>
|
||||
{
|
||||
return metadata.keys;
|
||||
}
|
||||
|
||||
protected function createMetadata() : Metadata
|
||||
{
|
||||
return new Metadata();
|
||||
}
|
||||
|
||||
public function get metadata() : Metadata
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
protected function addTrait(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 == null || param2 == null || param1 != param2.traitType)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc3_:MediaTraitResolver = traitResolvers[param1];
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.addTrait(param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalTrait(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc3_:MediaTraitBase = traits[param1];
|
||||
var _loc2_:MediaTraitResolver = traitResolvers[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
return _loc2_.removeTrait(_loc3_);
|
||||
}
|
||||
return setLocalTrait(param1,null);
|
||||
}
|
||||
|
||||
final protected function addTraitResolver(param1:String, param2:MediaTraitResolver) : void
|
||||
{
|
||||
var _loc3_:MediaTraitBase = null;
|
||||
if(param2 == null || param2.type != param1)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
if(traitResolvers[param1] == null)
|
||||
{
|
||||
unresolvedTraits[param1] = traits[param1];
|
||||
traitResolvers[param1] = param2;
|
||||
_loc3_ = traits[param1];
|
||||
if(_loc3_)
|
||||
{
|
||||
param2.addTrait(_loc3_);
|
||||
}
|
||||
processResolvedTraitChange(param1,param2.resolvedTrait);
|
||||
param2.addEventListener("change",onTraitResolverChange);
|
||||
return;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString("traitResolverAlreadyAdded"));
|
||||
}
|
||||
|
||||
final protected function removeTraitResolver(param1:String) : MediaTraitResolver
|
||||
{
|
||||
if(param1 == null || traitResolvers[param1] == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:MediaTraitResolver = traitResolvers[param1];
|
||||
_loc2_.removeEventListener("change",onTraitResolverChange);
|
||||
delete traitResolvers[param1];
|
||||
var _loc3_:MediaTraitBase = unresolvedTraits[param1];
|
||||
if(_loc3_ != traits[param1])
|
||||
{
|
||||
setLocalTrait(param1,_loc3_);
|
||||
}
|
||||
delete unresolvedTraits[param1];
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
final protected function getTraitResolver(param1:String) : MediaTraitResolver
|
||||
{
|
||||
return traitResolvers[param1];
|
||||
}
|
||||
|
||||
protected function setupTraitResolvers() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function setupTraits() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function onMediaError(param1:MediaErrorEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function setLocalTrait(param1:String, param2:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
var _loc3_:MediaTraitBase = traits[param1];
|
||||
if(param2 == null)
|
||||
{
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.removeEventListener("mediaError",onMediaError);
|
||||
_loc3_.dispose();
|
||||
dispatchEvent(new MediaElementEvent("traitRemove",false,false,param1));
|
||||
_traitTypes.splice(_traitTypes.indexOf(param1),1);
|
||||
delete traits[param1];
|
||||
}
|
||||
}
|
||||
else if(_loc3_ == null)
|
||||
{
|
||||
traits[param1] = _loc3_ = param2;
|
||||
_traitTypes.push(param1);
|
||||
_loc3_.addEventListener("mediaError",onMediaError);
|
||||
dispatchEvent(new MediaElementEvent("traitAdd",false,false,param1));
|
||||
}
|
||||
else if(_loc3_ != param2)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("traitInstanceAlreadyAdded"));
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function onTraitResolverChange(param1:Event) : void
|
||||
{
|
||||
var _loc2_:MediaTraitResolver = param1.target as MediaTraitResolver;
|
||||
processResolvedTraitChange(_loc2_.type,_loc2_.resolvedTrait);
|
||||
}
|
||||
|
||||
private function processResolvedTraitChange(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(param2 != traits[param1])
|
||||
{
|
||||
setLocalTrait(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
private function onContainerChange(param1:ContainerChangeEvent) : void
|
||||
{
|
||||
if(_container == param1.oldContainer && _container != param1.newContainer)
|
||||
{
|
||||
_container = param1.newContainer;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetadataValueAdd(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataAdd",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
|
||||
private function onMetadataValueChange(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataRemove",false,false,null,param1.key,param1.oldValue as Metadata));
|
||||
dispatchEvent(new MediaElementEvent("metadataAdd",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
|
||||
private function onMetadataValueRemove(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataRemove",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.elements.ProxyElement;
|
||||
import org.osmf.events.MediaFactoryEvent;
|
||||
import org.osmf.events.PluginManagerEvent;
|
||||
import org.osmf.media.pluginClasses.PluginManager;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaFactory extends EventDispatcher
|
||||
{
|
||||
|
||||
private var pluginManager:PluginManager;
|
||||
|
||||
private var allItems:Dictionary;
|
||||
|
||||
public function MediaFactory()
|
||||
{
|
||||
super();
|
||||
allItems = new Dictionary();
|
||||
}
|
||||
|
||||
private static function getItemsByResource(param1:MediaResourceBase, param2:Vector.<MediaFactoryItem>) : Vector.<MediaFactoryItem>
|
||||
{
|
||||
var _loc4_:Vector.<MediaFactoryItem> = new Vector.<MediaFactoryItem>();
|
||||
for each(var _loc3_:MediaFactoryItem in param2)
|
||||
{
|
||||
if(_loc3_.canHandleResourceFunction(param1))
|
||||
{
|
||||
_loc4_.push(_loc3_);
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private static function getIndexOfItem(param1:String, param2:Vector.<MediaFactoryItem>) : int
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MediaFactoryItem = null;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param2.length)
|
||||
{
|
||||
_loc3_ = param2[_loc4_] as MediaFactoryItem;
|
||||
if(_loc3_.id == param1)
|
||||
{
|
||||
return _loc4_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function addItem(param1:MediaFactoryItem) : void
|
||||
{
|
||||
if(param1 == null || param1.id == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:Vector.<MediaFactoryItem> = findOrCreateItems(param1.type);
|
||||
var _loc3_:int = getIndexOfItem(param1.id,_loc2_);
|
||||
if(_loc3_ != -1)
|
||||
{
|
||||
_loc2_[_loc3_] = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.push(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeItem(param1:MediaFactoryItem) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(param1 == null || param1.id == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:Vector.<MediaFactoryItem> = allItems[param1.type];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = _loc2_.indexOf(param1);
|
||||
if(_loc3_ != -1)
|
||||
{
|
||||
_loc2_.splice(_loc3_,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get numItems() : int
|
||||
{
|
||||
var _loc2_:* = undefined;
|
||||
var _loc3_:int = 0;
|
||||
for each(var _loc1_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc2_ = allItems[_loc1_];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ += _loc2_.length;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function getItemAt(param1:int) : MediaFactoryItem
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc2_:MediaFactoryItem = null;
|
||||
if(param1 >= 0)
|
||||
{
|
||||
for each(var _loc3_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc4_ = allItems[_loc3_];
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
if(param1 < _loc4_.length)
|
||||
{
|
||||
_loc2_ = _loc4_[param1];
|
||||
break;
|
||||
}
|
||||
param1 -= _loc4_.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function getItemById(param1:String) : MediaFactoryItem
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:MediaFactoryItem = null;
|
||||
for each(var _loc3_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc4_ = allItems[_loc3_];
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc5_ = getIndexOfItem(param1,_loc4_);
|
||||
if(_loc5_ != -1)
|
||||
{
|
||||
_loc2_ = _loc4_[_loc5_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function loadPlugin(param1:MediaResourceBase) : void
|
||||
{
|
||||
createPluginManager();
|
||||
pluginManager.loadPlugin(param1);
|
||||
}
|
||||
|
||||
public function createMediaElement(param1:MediaResourceBase) : MediaElement
|
||||
{
|
||||
var _loc3_:MediaElement = null;
|
||||
createPluginManager();
|
||||
var _loc2_:MediaElement = createMediaElementByResource(param1,"standard");
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = createMediaElementByResource(_loc2_.resource,"proxy",_loc2_);
|
||||
_loc2_ = _loc3_ != null ? _loc3_ : _loc2_;
|
||||
dispatchEvent(new MediaFactoryEvent("mediaElementCreate",false,false,null,_loc2_));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
protected function resolveItems(param1:MediaResourceBase, param2:Vector.<MediaFactoryItem>) : MediaFactoryItem
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:MediaFactoryItem = null;
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc4_:MediaFactoryItem = null;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param2.length)
|
||||
{
|
||||
_loc3_ = param2[_loc5_] as MediaFactoryItem;
|
||||
if(_loc3_.id.indexOf("org.osmf") == -1)
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = _loc3_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private function findOrCreateItems(param1:String) : Vector.<MediaFactoryItem>
|
||||
{
|
||||
if(allItems[param1] == null)
|
||||
{
|
||||
allItems[param1] = new Vector.<MediaFactoryItem>();
|
||||
}
|
||||
return allItems[param1] as Vector.<MediaFactoryItem>;
|
||||
}
|
||||
|
||||
private function createMediaElementByResource(param1:MediaResourceBase, param2:String, param3:MediaElement = null) : MediaElement
|
||||
{
|
||||
var _loc4_:MediaFactoryItem = null;
|
||||
var _loc8_:MediaElement = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:MediaFactoryItem = null;
|
||||
var _loc9_:ProxyElement = null;
|
||||
var _loc5_:MediaElement = null;
|
||||
var _loc10_:Vector.<MediaFactoryItem> = getItemsByResource(param1,allItems[param2]);
|
||||
if(param2 == "standard")
|
||||
{
|
||||
_loc4_ = resolveItems(param1,_loc10_) as MediaFactoryItem;
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc5_ = invokeMediaElementCreationFunction(_loc4_);
|
||||
}
|
||||
}
|
||||
else if(param2 == "proxy")
|
||||
{
|
||||
_loc8_ = param3;
|
||||
_loc6_ = int(_loc10_.length);
|
||||
while(_loc6_ > 0)
|
||||
{
|
||||
_loc7_ = _loc10_[_loc6_ - 1] as MediaFactoryItem;
|
||||
_loc9_ = invokeMediaElementCreationFunction(_loc7_) as ProxyElement;
|
||||
if(_loc9_ != null)
|
||||
{
|
||||
_loc9_.proxiedElement = _loc8_;
|
||||
_loc8_ = _loc9_;
|
||||
}
|
||||
_loc6_--;
|
||||
}
|
||||
_loc5_ = _loc8_;
|
||||
}
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc5_.resource = param1;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function onPluginLoad(param1:PluginManagerEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaFactoryEvent("pluginLoad",false,false,param1.resource));
|
||||
}
|
||||
|
||||
private function onPluginLoadError(param1:PluginManagerEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaFactoryEvent("pluginLoadError",false,false,param1.resource));
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationFunction(param1:MediaFactoryItem) : MediaElement
|
||||
{
|
||||
var _loc2_:MediaElement = null;
|
||||
try
|
||||
{
|
||||
_loc2_ = param1.mediaElementCreationFunction();
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function createPluginManager() : void
|
||||
{
|
||||
if(pluginManager == null)
|
||||
{
|
||||
pluginManager = new PluginManager(this);
|
||||
pluginManager.addEventListener("pluginLoad",onPluginLoad);
|
||||
pluginManager.addEventListener("pluginLoadError",onPluginLoadError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaFactoryItem
|
||||
{
|
||||
|
||||
private var _id:String;
|
||||
|
||||
private var _canHandleResourceFunction:Function;
|
||||
|
||||
private var _mediaElementCreationFunction:Function;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
public function MediaFactoryItem(param1:String, param2:Function, param3:Function, param4:String = null)
|
||||
{
|
||||
super();
|
||||
if(param1 == null || param2 == null || param3 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
if(!param4)
|
||||
{
|
||||
param4 = "standard";
|
||||
}
|
||||
_id = param1;
|
||||
_canHandleResourceFunction = param2;
|
||||
_mediaElementCreationFunction = param3;
|
||||
_type = param4;
|
||||
}
|
||||
|
||||
public function get id() : String
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public function get canHandleResourceFunction() : Function
|
||||
{
|
||||
return _canHandleResourceFunction;
|
||||
}
|
||||
|
||||
public function get mediaElementCreationFunction() : Function
|
||||
{
|
||||
return _mediaElementCreationFunction;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public class MediaFactoryItemType
|
||||
{
|
||||
|
||||
public static const STANDARD:String = "standard";
|
||||
|
||||
public static const PROXY:String = "proxy";
|
||||
|
||||
internal static const ALL_TYPES:Array = ["standard","proxy"];
|
||||
|
||||
public function MediaFactoryItemType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public final class MediaPlayerState
|
||||
{
|
||||
|
||||
public static const UNINITIALIZED:String = "uninitialized";
|
||||
|
||||
public static const LOADING:String = "loading";
|
||||
|
||||
public static const READY:String = "ready";
|
||||
|
||||
public static const PLAYING:String = "playing";
|
||||
|
||||
public static const PAUSED:String = "paused";
|
||||
|
||||
public static const BUFFERING:String = "buffering";
|
||||
|
||||
public static const PLAYBACK_ERROR:String = "playbackError";
|
||||
|
||||
public function MediaPlayerState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class MediaResourceBase
|
||||
{
|
||||
|
||||
private var _metadata:Dictionary;
|
||||
|
||||
private var _mediaType:String;
|
||||
|
||||
private var _mimeType:String;
|
||||
|
||||
public function MediaResourceBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get mediaType() : String
|
||||
{
|
||||
return _mediaType;
|
||||
}
|
||||
|
||||
public function set mediaType(param1:String) : void
|
||||
{
|
||||
_mediaType = param1;
|
||||
}
|
||||
|
||||
public function get mimeType() : String
|
||||
{
|
||||
return _mimeType;
|
||||
}
|
||||
|
||||
public function set mimeType(param1:String) : void
|
||||
{
|
||||
_mimeType = param1;
|
||||
}
|
||||
|
||||
public function get metadataNamespaceURLs() : Vector.<String>
|
||||
{
|
||||
var _loc1_:Vector.<String> = new Vector.<String>();
|
||||
if(_metadata != null)
|
||||
{
|
||||
for(var _loc2_:String in _metadata)
|
||||
{
|
||||
_loc1_.push(_loc2_);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function addMetadataValue(param1:String, param2:Object) : void
|
||||
{
|
||||
if(_metadata == null)
|
||||
{
|
||||
_metadata = new Dictionary();
|
||||
}
|
||||
_metadata[param1] = param2;
|
||||
}
|
||||
|
||||
public function getMetadataValue(param1:String) : Object
|
||||
{
|
||||
if(_metadata != null)
|
||||
{
|
||||
return _metadata[param1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function removeMetadataValue(param1:String) : Object
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(_metadata != null)
|
||||
{
|
||||
_loc2_ = _metadata[param1];
|
||||
delete _metadata[param1];
|
||||
return _loc2_;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class MediaTraitResolver extends EventDispatcher
|
||||
{
|
||||
|
||||
private var _type:String;
|
||||
|
||||
private var _resolvedTrait:MediaTraitBase;
|
||||
|
||||
public function MediaTraitResolver(param1:String)
|
||||
{
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
_type = param1;
|
||||
}
|
||||
|
||||
final public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
final protected function setResolvedTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 != _resolvedTrait)
|
||||
{
|
||||
if(_resolvedTrait)
|
||||
{
|
||||
_resolvedTrait = null;
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
_resolvedTrait = param1;
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
}
|
||||
|
||||
final public function get resolvedTrait() : MediaTraitBase
|
||||
{
|
||||
return _resolvedTrait;
|
||||
}
|
||||
|
||||
final public function addTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param1.traitType != type)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
processAddTrait(param1);
|
||||
}
|
||||
|
||||
final public function removeTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param1.traitType != type)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return processRemoveTrait(param1);
|
||||
}
|
||||
|
||||
protected function processAddTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processRemoveTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public final class MediaType
|
||||
{
|
||||
|
||||
public static const VIDEO:String = "video";
|
||||
|
||||
public static const AUDIO:String = "audio";
|
||||
|
||||
public static const IMAGE:String = "image";
|
||||
|
||||
public static const SWF:String = "swf";
|
||||
|
||||
public function MediaType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public class MediaTypeUtil
|
||||
{
|
||||
|
||||
public static const METADATA_MATCH_FOUND:int = 0;
|
||||
|
||||
public static const METADATA_CONFLICTS_FOUND:int = 1;
|
||||
|
||||
public static const METADATA_MATCH_UNKNOWN:int = 2;
|
||||
|
||||
public function MediaTypeUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function checkMetadataMatchWithResource(param1:MediaResourceBase, param2:Vector.<String>, param3:Vector.<String>) : int
|
||||
{
|
||||
var _loc4_:String = param1 ? param1.mediaType : null;
|
||||
var _loc5_:String = param1 ? param1.mimeType : null;
|
||||
return checkMetadataMatch(_loc4_,_loc5_,param2,param3);
|
||||
}
|
||||
|
||||
public static function checkMetadataMatch(param1:String, param2:String, param3:Vector.<String>, param4:Vector.<String>) : int
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(param2 != null)
|
||||
{
|
||||
return matchType(param1,param3) && matchType(param2,param4) ? METADATA_MATCH_FOUND : 1;
|
||||
}
|
||||
return matchType(param1,param3) ? METADATA_MATCH_FOUND : 1;
|
||||
}
|
||||
if(param2 != null)
|
||||
{
|
||||
return matchType(param2,param4) ? METADATA_MATCH_FOUND : 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static function matchType(param1:String, param2:Vector.<String>) : Boolean
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param2.length)
|
||||
{
|
||||
if(param1 == param2[_loc3_])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.media.pluginClasses.VersionUtils;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.Version;
|
||||
|
||||
public class PluginInfo
|
||||
{
|
||||
|
||||
public static const PLUGIN_MEDIAFACTORY_NAMESPACE:String = "http://www.osmf.org/plugin/mediaFactory/1.0";
|
||||
|
||||
private var _mediaFactoryItems:Vector.<MediaFactoryItem>;
|
||||
|
||||
private var _mediaElementCreationNotificationFunction:Function;
|
||||
|
||||
public function PluginInfo(param1:Vector.<MediaFactoryItem> = null, param2:Function = null)
|
||||
{
|
||||
super();
|
||||
_mediaFactoryItems = param1 != null ? param1 : new Vector.<MediaFactoryItem>();
|
||||
_mediaElementCreationNotificationFunction = param2;
|
||||
}
|
||||
|
||||
public function get numMediaFactoryItems() : int
|
||||
{
|
||||
return _mediaFactoryItems.length;
|
||||
}
|
||||
|
||||
public function get frameworkVersion() : String
|
||||
{
|
||||
return Version.version;
|
||||
}
|
||||
|
||||
public function getMediaFactoryItemAt(param1:int) : MediaFactoryItem
|
||||
{
|
||||
if(param1 < 0 || param1 >= _mediaFactoryItems.length)
|
||||
{
|
||||
throw new RangeError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return _mediaFactoryItems[param1] as MediaFactoryItem;
|
||||
}
|
||||
|
||||
public function isFrameworkVersionSupported(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null || param1.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc3_:Object = VersionUtils.parseVersionString(param1);
|
||||
var _loc2_:Object = VersionUtils.parseVersionString(frameworkVersion);
|
||||
return _loc3_.major > _loc2_.major || _loc3_.major == _loc2_.major && _loc3_.minor >= _loc2_.minor;
|
||||
}
|
||||
|
||||
public function initializePlugin(param1:MediaResourceBase) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get mediaElementCreationNotificationFunction() : Function
|
||||
{
|
||||
return _mediaElementCreationNotificationFunction;
|
||||
}
|
||||
|
||||
final protected function get mediaFactoryItems() : Vector.<MediaFactoryItem>
|
||||
{
|
||||
return _mediaFactoryItems;
|
||||
}
|
||||
|
||||
final protected function set mediaFactoryItems(param1:Vector.<MediaFactoryItem>) : void
|
||||
{
|
||||
_mediaFactoryItems = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public class PluginInfoResource extends MediaResourceBase
|
||||
{
|
||||
|
||||
private var _pluginInfo:PluginInfo;
|
||||
|
||||
public function PluginInfoResource(param1:PluginInfo)
|
||||
{
|
||||
super();
|
||||
_pluginInfo = param1;
|
||||
}
|
||||
|
||||
public function get pluginInfo() : PluginInfo
|
||||
{
|
||||
return _pluginInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public class URLResource extends MediaResourceBase
|
||||
{
|
||||
|
||||
private var _url:String;
|
||||
|
||||
public function URLResource(param1:String)
|
||||
{
|
||||
super();
|
||||
_url = param1;
|
||||
}
|
||||
|
||||
public function get url() : String
|
||||
{
|
||||
return _url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
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.LoadTrait;
|
||||
|
||||
internal class DynamicPluginLoader extends PluginLoader
|
||||
{
|
||||
|
||||
private static const PLUGININFO_PROPERTY_NAME:String = "pluginInfo";
|
||||
|
||||
public function DynamicPluginLoader(param1:MediaFactory, param2:String)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
return new SWFLoader().canHandleResource(param1);
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
var swfLoader:SWFLoader;
|
||||
var loaderLoadTrait:LoaderLoadTrait;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var onSWFLoaderStateChange:* = function(param1:LoaderEvent):void
|
||||
{
|
||||
var _loc2_:DisplayObject = null;
|
||||
var _loc3_:PluginInfo = null;
|
||||
if(param1.newState == "ready")
|
||||
{
|
||||
swfLoader.removeEventListener("loadStateChange",onSWFLoaderStateChange);
|
||||
loaderLoadTrait.removeEventListener("mediaError",onLoadError);
|
||||
_loc2_ = loaderLoadTrait.loader.content;
|
||||
_loc3_ = _loc2_["pluginInfo"] as PluginInfo;
|
||||
loadFromPluginInfo(loadTrait,_loc3_,loaderLoadTrait.loader);
|
||||
}
|
||||
else if(param1.newState == "loadError")
|
||||
{
|
||||
swfLoader.removeEventListener("loadStateChange",onSWFLoaderStateChange);
|
||||
updateLoadTrait(loadTrait,param1.newState);
|
||||
}
|
||||
};
|
||||
var onLoadError:* = function(param1:MediaErrorEvent):void
|
||||
{
|
||||
loaderLoadTrait.removeEventListener("mediaError",onLoadError);
|
||||
loadTrait.dispatchEvent(param1.clone());
|
||||
};
|
||||
updateLoadTrait(loadTrait,"loading");
|
||||
swfLoader = new SWFLoader(true);
|
||||
swfLoader.validateLoadedContentFunction = validateLoadedContent;
|
||||
swfLoader.addEventListener("loadStateChange",onSWFLoaderStateChange);
|
||||
loaderLoadTrait = new LoaderLoadTrait(swfLoader,loadTrait.resource);
|
||||
loaderLoadTrait.addEventListener("mediaError",onLoadError);
|
||||
swfLoader.load(loaderLoadTrait);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,"unloading");
|
||||
var _loc2_:PluginLoadTrait = param1 as PluginLoadTrait;
|
||||
unloadFromPluginInfo(_loc2_.pluginInfo);
|
||||
_loc2_.loader.unloadAndStop();
|
||||
updateLoadTrait(param1,"uninitialized");
|
||||
}
|
||||
|
||||
private function validateLoadedContent(param1:DisplayObject) : Boolean
|
||||
{
|
||||
var _loc2_:Object = param1.hasOwnProperty("pluginInfo") ? param1["pluginInfo"] : null;
|
||||
return _loc2_ != null ? isPluginCompatible(_loc2_) : 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(param1:PluginLoader, param2:MediaResourceBase = null)
|
||||
{
|
||||
super(param2,param1);
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new PluginLoadTrait(param2,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(param1:MediaElement, param2:PluginLoadingState)
|
||||
{
|
||||
super();
|
||||
_pluginElement = param1;
|
||||
_state = param2;
|
||||
}
|
||||
|
||||
public function get pluginElement() : MediaElement
|
||||
{
|
||||
return _pluginElement;
|
||||
}
|
||||
|
||||
public function get state() : PluginLoadingState
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public function set state(param1:PluginLoadingState) : void
|
||||
{
|
||||
_state = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
|
||||
internal class PluginLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _pluginInfo:PluginInfo;
|
||||
|
||||
private var _loader:Loader;
|
||||
|
||||
public function PluginLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get pluginInfo() : PluginInfo
|
||||
{
|
||||
return _pluginInfo;
|
||||
}
|
||||
|
||||
public function set pluginInfo(param1:PluginInfo) : void
|
||||
{
|
||||
_pluginInfo = param1;
|
||||
}
|
||||
|
||||
public function get loader() : Loader
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
public function set loader(param1:Loader) : void
|
||||
{
|
||||
_loader = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaFactoryItem;
|
||||
import org.osmf.media.PluginInfo;
|
||||
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(param1:MediaFactory, param2:String)
|
||||
{
|
||||
super();
|
||||
this.mediaFactory = param1;
|
||||
this.minimumSupportedFrameworkVersion = param2;
|
||||
}
|
||||
|
||||
protected function unloadFromPluginInfo(param1:PluginInfo) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:MediaFactoryItem = null;
|
||||
var _loc3_:MediaFactoryItem = null;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.numMediaFactoryItems)
|
||||
{
|
||||
_loc2_ = param1.getMediaFactoryItemAt(_loc4_);
|
||||
_loc3_ = mediaFactory.getItemById(_loc2_.id);
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
mediaFactory.removeItem(_loc3_);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadFromPluginInfo(param1:LoadTrait, param2:PluginInfo, param3:Loader = null) : void
|
||||
{
|
||||
var _loc4_:MediaFactory = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:MediaFactoryItem = null;
|
||||
var _loc6_:PluginLoadTrait = null;
|
||||
var _loc8_:Boolean = false;
|
||||
if(param2 != null)
|
||||
{
|
||||
if(isPluginCompatible(param2))
|
||||
{
|
||||
try
|
||||
{
|
||||
_loc4_ = param1.resource.getMetadataValue("http://www.osmf.org/plugin/mediaFactory/1.0") as MediaFactory;
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
param1.resource.addMetadataValue("http://www.osmf.org/plugin/mediaFactory/1.0",mediaFactory);
|
||||
}
|
||||
param2.initializePlugin(param1.resource);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < param2.numMediaFactoryItems)
|
||||
{
|
||||
_loc5_ = param2.getMediaFactoryItemAt(_loc7_);
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
throw new RangeError();
|
||||
}
|
||||
mediaFactory.addItem(_loc5_);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_ = param1 as PluginLoadTrait;
|
||||
_loc6_.pluginInfo = param2;
|
||||
_loc6_.loader = param3;
|
||||
updateLoadTrait(_loc6_,"ready");
|
||||
}
|
||||
catch(error:RangeError)
|
||||
{
|
||||
_loc8_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLoadTrait(param1,"loadError");
|
||||
param1.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(8)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = true;
|
||||
}
|
||||
if(_loc8_)
|
||||
{
|
||||
updateLoadTrait(param1,"loadError");
|
||||
param1.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(9)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function isPluginCompatible(param1:Object) : Boolean
|
||||
{
|
||||
var _loc2_:Function = null;
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc4_:String = param1.hasOwnProperty("frameworkVersion") ? param1["frameworkVersion"] : null;
|
||||
var _loc3_:Boolean = isPluginVersionSupported(_loc4_);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc2_ = param1.hasOwnProperty("isFrameworkVersionSupported") ? param1["isFrameworkVersionSupported"] as Function : null;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_loc5_ = _loc2_(Version.version);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function isPluginVersionSupported(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null || param1.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc2_:Object = VersionUtils.parseVersionString(minimumSupportedFrameworkVersion);
|
||||
var _loc3_:Object = VersionUtils.parseVersionString(param1);
|
||||
return _loc3_.major > _loc2_.major || _loc3_.major == _loc2_.major && _loc3_.minor >= _loc2_.minor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(param1:String)
|
||||
{
|
||||
super();
|
||||
_state = param1;
|
||||
}
|
||||
|
||||
public function get state() : String
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
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.LoadTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.Version;
|
||||
|
||||
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(param1:MediaFactory)
|
||||
{
|
||||
super();
|
||||
_mediaFactory = param1;
|
||||
_mediaFactory.addEventListener("mediaElementCreate",onMediaElementCreate);
|
||||
minimumSupportedFrameworkVersion = Version.lastAPICompatibleVersion;
|
||||
initPluginFactory();
|
||||
_pluginMap = new Dictionary();
|
||||
_pluginList = new Vector.<PluginEntry>();
|
||||
}
|
||||
|
||||
public function loadPlugin(param1:MediaResourceBase) : void
|
||||
{
|
||||
var identifier:Object;
|
||||
var pluginEntry:PluginEntry;
|
||||
var pluginElement:MediaElement;
|
||||
var loadTrait:LoadTrait;
|
||||
var resource:MediaResourceBase = param1;
|
||||
var onLoadStateChange:* = function(param1:LoadEvent):void
|
||||
{
|
||||
var _loc2_:PluginLoadTrait = null;
|
||||
if(param1.loadState == "ready")
|
||||
{
|
||||
pluginEntry.state = PluginLoadingState.LOADED;
|
||||
_pluginList.push(pluginEntry);
|
||||
_loc2_ = pluginElement.getTrait("load") as PluginLoadTrait;
|
||||
if(_loc2_.pluginInfo.mediaElementCreationNotificationFunction != null)
|
||||
{
|
||||
invokeMediaElementCreationNotificationForCreatedMediaElements(_loc2_.pluginInfo.mediaElementCreationNotificationFunction);
|
||||
if(notificationFunctions == null)
|
||||
{
|
||||
notificationFunctions = new Vector.<Function>();
|
||||
}
|
||||
notificationFunctions.push(_loc2_.pluginInfo.mediaElementCreationNotificationFunction);
|
||||
}
|
||||
dispatchEvent(new PluginManagerEvent("pluginLoad",false,false,resource));
|
||||
}
|
||||
else if(param1.loadState == "loadError")
|
||||
{
|
||||
delete _pluginMap[identifier];
|
||||
dispatchEvent(new PluginManagerEvent("pluginLoadError",false,false,resource));
|
||||
}
|
||||
};
|
||||
var onMediaError:* = function(param1:MediaErrorEvent):void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
};
|
||||
if(resource == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
identifier = getPluginIdentifier(resource);
|
||||
pluginEntry = _pluginMap[identifier] as PluginEntry;
|
||||
if(pluginEntry != null)
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent("pluginLoad",false,false,resource));
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginElement = _pluginFactory.createMediaElement(resource);
|
||||
if(pluginElement != null)
|
||||
{
|
||||
pluginEntry = new PluginEntry(pluginElement,PluginLoadingState.LOADING);
|
||||
_pluginMap[identifier] = pluginEntry;
|
||||
loadTrait = pluginElement.getTrait("load") as LoadTrait;
|
||||
if(loadTrait != null)
|
||||
{
|
||||
loadTrait.addEventListener("loadStateChange",onLoadStateChange);
|
||||
loadTrait.addEventListener("mediaError",onMediaError);
|
||||
loadTrait.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent("pluginLoadError",false,false,resource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(new PluginManagerEvent("pluginLoadError",false,false,resource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get mediaFactory() : MediaFactory
|
||||
{
|
||||
return _mediaFactory;
|
||||
}
|
||||
|
||||
private function getPluginIdentifier(param1:MediaResourceBase) : Object
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(param1 is URLResource)
|
||||
{
|
||||
_loc2_ = (param1 as URLResource).url;
|
||||
}
|
||||
else if(param1 is PluginInfoResource)
|
||||
{
|
||||
_loc2_ = (param1 as PluginInfoResource).pluginInfo;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function initPluginFactory() : void
|
||||
{
|
||||
_pluginFactory = new MediaFactory();
|
||||
staticPluginLoader = new StaticPluginLoader(mediaFactory,minimumSupportedFrameworkVersion);
|
||||
dynamicPluginLoader = new DynamicPluginLoader(mediaFactory,minimumSupportedFrameworkVersion);
|
||||
var _loc1_:MediaFactoryItem = new MediaFactoryItem("org.osmf.plugins.StaticPluginLoader",staticPluginLoader.canHandleResource,createStaticPluginElement);
|
||||
_pluginFactory.addItem(_loc1_);
|
||||
var _loc2_:MediaFactoryItem = new MediaFactoryItem("org.osmf.plugins.DynamicPluginLoader",dynamicPluginLoader.canHandleResource,createDynamicPluginElement);
|
||||
_pluginFactory.addItem(_loc2_);
|
||||
}
|
||||
|
||||
private function createStaticPluginElement() : MediaElement
|
||||
{
|
||||
return new PluginElement(staticPluginLoader);
|
||||
}
|
||||
|
||||
private function createDynamicPluginElement() : MediaElement
|
||||
{
|
||||
return new PluginElement(dynamicPluginLoader);
|
||||
}
|
||||
|
||||
private function onMediaElementCreate(param1:MediaFactoryEvent) : void
|
||||
{
|
||||
invokeMediaElementCreationNotifications(param1.mediaElement);
|
||||
if(createdElements == null)
|
||||
{
|
||||
createdElements = new Dictionary(true);
|
||||
}
|
||||
createdElements[param1.mediaElement] = true;
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotifications(param1:MediaElement) : void
|
||||
{
|
||||
for each(var _loc2_:Function in notificationFunctions)
|
||||
{
|
||||
invokeMediaElementCreationNotificationFunction(_loc2_,param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotificationFunction(param1:Function, param2:MediaElement) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
param1.call(null,param2);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationNotificationForCreatedMediaElements(param1:Function) : void
|
||||
{
|
||||
for(var _loc2_:Object in createdElements)
|
||||
{
|
||||
invokeMediaElementCreationNotificationFunction(param1,_loc2_ as MediaElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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.LoadTrait;
|
||||
|
||||
internal class StaticPluginLoader extends PluginLoader
|
||||
{
|
||||
|
||||
public function StaticPluginLoader(param1:MediaFactory, param2:String)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
return param1 is PluginInfoResource;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,"loading");
|
||||
var _loc2_:PluginInfoResource = param1.resource as PluginInfoResource;
|
||||
var _loc3_:PluginInfo = _loc2_.pluginInfo;
|
||||
loadFromPluginInfo(param1,_loc3_);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
var _loc2_:PluginLoadTrait = param1 as PluginLoadTrait;
|
||||
var _loc3_:PluginInfo = _loc2_.pluginInfo;
|
||||
updateLoadTrait(param1,"unloading");
|
||||
unloadFromPluginInfo(_loc3_);
|
||||
updateLoadTrait(param1,"uninitialized");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.media.pluginClasses
|
||||
{
|
||||
public class VersionUtils
|
||||
{
|
||||
|
||||
public function VersionUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function parseVersionString(param1:String) : Object
|
||||
{
|
||||
var _loc4_:Array = param1.split(".");
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
if(_loc4_.length >= 1)
|
||||
{
|
||||
_loc2_ = parseInt(_loc4_[0]);
|
||||
}
|
||||
if(_loc4_.length >= 2)
|
||||
{
|
||||
_loc3_ = parseInt(_loc4_[1]);
|
||||
if(_loc3_ < 10)
|
||||
{
|
||||
_loc3_ *= 10;
|
||||
}
|
||||
}
|
||||
return {
|
||||
"major":_loc2_,
|
||||
"minor":_loc3_
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user