mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 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,183 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.NetStream;
|
||||
import org.osmf.elements.audioClasses.AudioAudioTrait;
|
||||
import org.osmf.elements.audioClasses.AudioPlayTrait;
|
||||
import org.osmf.elements.audioClasses.AudioSeekTrait;
|
||||
import org.osmf.elements.audioClasses.AudioTimeTrait;
|
||||
import org.osmf.elements.audioClasses.SoundAdapter;
|
||||
import org.osmf.elements.audioClasses.SoundLoadTrait;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.DefaultTraitResolver;
|
||||
import org.osmf.media.LoadableElementBase;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.*;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class AudioElement extends LoadableElementBase
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var defaultTimeTrait:ModifiableTimeTrait;
|
||||
|
||||
private var _alternateLoaders:Vector.<LoaderBase>;
|
||||
|
||||
public function AudioElement(param1:URLResource = null, param2:LoaderBase = null)
|
||||
{
|
||||
super(param1,param2);
|
||||
if(!(param2 == null || param2 is NetLoader || param2 is SoundLoader))
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function get defaultDuration() : Number
|
||||
{
|
||||
return this.defaultTimeTrait ? this.defaultTimeTrait.duration : NaN;
|
||||
}
|
||||
|
||||
public function set defaultDuration(param1:Number) : void
|
||||
{
|
||||
if(isNaN(param1) || param1 < 0)
|
||||
{
|
||||
if(this.defaultTimeTrait != null)
|
||||
{
|
||||
removeTraitResolver(MediaTraitType.TIME);
|
||||
this.defaultTimeTrait = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.defaultTimeTrait == null)
|
||||
{
|
||||
this.defaultTimeTrait = new ModifiableTimeTrait();
|
||||
addTraitResolver(MediaTraitType.TIME,new DefaultTraitResolver(MediaTraitType.TIME,this.defaultTimeTrait));
|
||||
}
|
||||
this.defaultTimeTrait.duration = param1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
loader = getLoaderForResource(param1,this.alternateLoaders);
|
||||
super.resource = param1;
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return param2 is NetLoader ? new NetStreamLoadTrait(param2,param1) : new SoundLoadTrait(param2,param1);
|
||||
}
|
||||
|
||||
override protected function processReadyState() : void
|
||||
{
|
||||
var _loc2_:TimeTrait = null;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:SoundLoadTrait = null;
|
||||
var _loc1_:LoadTrait = getTrait(MediaTraitType.LOAD) as LoadTrait;
|
||||
this.soundAdapter = null;
|
||||
this.stream = null;
|
||||
var _loc3_:NetStreamLoadTrait = _loc1_ as NetStreamLoadTrait;
|
||||
if(_loc3_)
|
||||
{
|
||||
this.stream = _loc3_.netStream;
|
||||
this.stream.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
_loc3_.connection.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent,false,0,true);
|
||||
_loc4_ = false;
|
||||
if(loader is NetLoader)
|
||||
{
|
||||
_loc4_ = (loader as NetLoader).reconnectStreams;
|
||||
}
|
||||
addTrait(MediaTraitType.PLAY,new NetStreamPlayTrait(this.stream,resource,_loc4_,_loc3_.connection));
|
||||
_loc2_ = new NetStreamTimeTrait(this.stream,resource,this.defaultDuration);
|
||||
addTrait(MediaTraitType.TIME,_loc2_);
|
||||
addTrait(MediaTraitType.SEEK,new NetStreamSeekTrait(_loc2_,_loc1_,this.stream));
|
||||
addTrait(MediaTraitType.AUDIO,new NetStreamAudioTrait(this.stream));
|
||||
addTrait(MediaTraitType.BUFFER,new NetStreamBufferTrait(this.stream));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc1_ as SoundLoadTrait;
|
||||
this.soundAdapter = new SoundAdapter(this,_loc5_.sound);
|
||||
addTrait(MediaTraitType.PLAY,new AudioPlayTrait(this.soundAdapter));
|
||||
_loc2_ = new AudioTimeTrait(this.soundAdapter);
|
||||
addTrait(MediaTraitType.TIME,_loc2_);
|
||||
addTrait(MediaTraitType.SEEK,new AudioSeekTrait(_loc2_,this.soundAdapter));
|
||||
addTrait(MediaTraitType.AUDIO,new AudioAudioTrait(this.soundAdapter));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
if(this.stream != null)
|
||||
{
|
||||
this.stream.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
}
|
||||
var _loc1_:NetStreamLoadTrait = getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
_loc1_.connection.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
}
|
||||
removeTrait(MediaTraitType.PLAY);
|
||||
removeTrait(MediaTraitType.SEEK);
|
||||
removeTrait(MediaTraitType.TIME);
|
||||
removeTrait(MediaTraitType.AUDIO);
|
||||
removeTrait(MediaTraitType.BUFFER);
|
||||
if(this.soundAdapter != null)
|
||||
{
|
||||
this.soundAdapter.pause();
|
||||
}
|
||||
this.soundAdapter = null;
|
||||
this.stream = null;
|
||||
}
|
||||
|
||||
private function onNetStatusEvent(param1:NetStatusEvent) : void
|
||||
{
|
||||
var _loc2_:MediaError = null;
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FAILED:
|
||||
case NetStreamCodes.NETSTREAM_FAILED:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_PLAY_FAILED,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STREAMNOTFOUND:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_STREAM_NOT_FOUND,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FILESTRUCTUREINVALID:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_FILE_STRUCTURE_INVALID,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_NOSUPPORTEDTRACKFOUND:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_NO_SUPPORTED_TRACK_FOUND,param1.info.description);
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_IDLE_TIME_OUT:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETCONNECTION_TIMEOUT,param1.info.description);
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function get alternateLoaders() : Vector.<LoaderBase>
|
||||
{
|
||||
if(this._alternateLoaders == null)
|
||||
{
|
||||
this._alternateLoaders = new Vector.<LoaderBase>();
|
||||
this._alternateLoaders.push(new SoundLoader());
|
||||
this._alternateLoaders.push(new NetLoader());
|
||||
}
|
||||
return this._alternateLoaders;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.media.URLResource;
|
||||
|
||||
public class F4MElement extends LoadFromDocumentElement
|
||||
{
|
||||
|
||||
public function F4MElement(param1:URLResource = null, param2:F4MLoader = null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new F4MLoader();
|
||||
}
|
||||
super(param1,param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLLoaderDataFormat;
|
||||
import flash.net.URLRequest;
|
||||
import org.osmf.elements.f4mClasses.DRMAdditionalHeader;
|
||||
import org.osmf.elements.f4mClasses.Manifest;
|
||||
import org.osmf.elements.f4mClasses.ManifestParser;
|
||||
import org.osmf.elements.proxyClasses.LoadFromDocumentLoadTrait;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.DefaultMediaFactory;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaFactory;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaTypeUtil;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingUtils;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class F4MLoader extends LoaderBase
|
||||
{
|
||||
|
||||
public static const F4M_MIME_TYPE:String = "application/f4m+xml";
|
||||
|
||||
private static const F4M_EXTENSION:String = "f4m";
|
||||
|
||||
private var supportedMimeTypes:Vector.<String> = new Vector.<String>();
|
||||
|
||||
private var factory:MediaFactory;
|
||||
|
||||
private var parser:ManifestParser;
|
||||
|
||||
public function F4MLoader(param1:MediaFactory = null)
|
||||
{
|
||||
super();
|
||||
this.supportedMimeTypes.push(F4M_MIME_TYPE);
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = new DefaultMediaFactory();
|
||||
}
|
||||
this.parser = new ManifestParser();
|
||||
this.factory = param1;
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc3_:URLResource = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,new Vector.<String>(),this.supportedMimeTypes);
|
||||
if(_loc2_ == MediaTypeUtil.METADATA_MATCH_FOUND)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(param1 is URLResource)
|
||||
{
|
||||
_loc3_ = URLResource(param1);
|
||||
_loc4_ = new URL(_loc3_.url).extension;
|
||||
return _loc4_ == F4M_EXTENSION;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
var manifest:Manifest = null;
|
||||
var manifestLoader:URLLoader = null;
|
||||
var onError:Function = null;
|
||||
var onComplete:Function = null;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
onError = function(param1:ErrorEvent):void
|
||||
{
|
||||
manifestLoader.removeEventListener(Event.COMPLETE,onComplete);
|
||||
manifestLoader.removeEventListener(IOErrorEvent.IO_ERROR,onError);
|
||||
manifestLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(0,param1.text)));
|
||||
};
|
||||
onComplete = function(param1:Event):void
|
||||
{
|
||||
var completionCallback:Function;
|
||||
var unfinishedLoads:Number = NaN;
|
||||
var item:DRMAdditionalHeader = null;
|
||||
var event:Event = param1;
|
||||
manifestLoader.removeEventListener(Event.COMPLETE,onComplete);
|
||||
manifestLoader.removeEventListener(IOErrorEvent.IO_ERROR,onError);
|
||||
manifestLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
|
||||
try
|
||||
{
|
||||
manifest = parser.parse(event.target.data,getRootUrl(URLResource(loadTrait.resource).url));
|
||||
}
|
||||
catch(parseError:Error)
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(parseError.errorID,parseError.message)));
|
||||
}
|
||||
if(manifest != null)
|
||||
{
|
||||
unfinishedLoads = 0;
|
||||
for each(item in manifest.drmAdditionalHeaders)
|
||||
{
|
||||
if(item.url != null)
|
||||
{
|
||||
completionCallback = function(param1:Boolean):void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
--unfinishedLoads;
|
||||
}
|
||||
if(unfinishedLoads == 0)
|
||||
{
|
||||
finishLoad();
|
||||
}
|
||||
};
|
||||
unfinishedLoads++;
|
||||
loadAdditionalHeader(item,completionCallback,onError);
|
||||
}
|
||||
}
|
||||
if(unfinishedLoads == 0)
|
||||
{
|
||||
finishLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
var finishLoad:Function = function():void
|
||||
{
|
||||
var netResource:MediaResourceBase = null;
|
||||
var loadedElem:MediaElement = null;
|
||||
var s:OSMFStrings = null;
|
||||
try
|
||||
{
|
||||
netResource = parser.createResource(manifest,URLResource(loadTrait.resource));
|
||||
loadedElem = factory.createMediaElement(netResource);
|
||||
if(loadedElem.hasOwnProperty("defaultDuration") && !isNaN(manifest.duration))
|
||||
{
|
||||
loadedElem["defaultDuration"] = manifest.duration;
|
||||
}
|
||||
LoadFromDocumentLoadTrait(loadTrait).mediaElement = loadedElem;
|
||||
updateLoadTrait(loadTrait,LoadState.READY);
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.F4M_FILE_INVALID,error.message)));
|
||||
}
|
||||
};
|
||||
updateLoadTrait(loadTrait,LoadState.LOADING);
|
||||
manifestLoader = new URLLoader(new URLRequest(URLResource(loadTrait.resource).url));
|
||||
manifestLoader.addEventListener(Event.COMPLETE,onComplete);
|
||||
manifestLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
|
||||
manifestLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,LoadState.UNINITIALIZED);
|
||||
}
|
||||
|
||||
private function loadAdditionalHeader(param1:DRMAdditionalHeader, param2:Function, param3:Function) : void
|
||||
{
|
||||
var onDRMLoadComplete:Function = null;
|
||||
var item:DRMAdditionalHeader = param1;
|
||||
var completionCallback:Function = param2;
|
||||
var onError:Function = param3;
|
||||
onDRMLoadComplete = function(param1:Event):void
|
||||
{
|
||||
param1.target.removeEventListener(Event.COMPLETE,onDRMLoadComplete);
|
||||
param1.target.removeEventListener(IOErrorEvent.IO_ERROR,onError);
|
||||
param1.target.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
|
||||
item.data = URLLoader(param1.target).data;
|
||||
completionCallback(true);
|
||||
};
|
||||
var drmLoader:URLLoader = new URLLoader();
|
||||
drmLoader.dataFormat = URLLoaderDataFormat.BINARY;
|
||||
drmLoader.addEventListener(Event.COMPLETE,onDRMLoadComplete);
|
||||
drmLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
|
||||
drmLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onError);
|
||||
drmLoader.load(new URLRequest(HTTPStreamingUtils.normalizeURL(item.url)));
|
||||
}
|
||||
|
||||
private function getRootUrl(param1:String) : String
|
||||
{
|
||||
return param1.substr(0,param1.lastIndexOf("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.Loader;
|
||||
import org.osmf.elements.loaderClasses.LoaderLoadTrait;
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.LoadableElementBase;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
|
||||
public class ImageElement extends LoadableElementBase
|
||||
{
|
||||
|
||||
private var _smoothing:Boolean;
|
||||
|
||||
public function ImageElement(param1:URLResource = null, param2:ImageLoader = null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new ImageLoader();
|
||||
}
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get smoothing() : Boolean
|
||||
{
|
||||
return this._smoothing;
|
||||
}
|
||||
|
||||
public function set smoothing(param1:Boolean) : void
|
||||
{
|
||||
if(this._smoothing != param1)
|
||||
{
|
||||
this._smoothing = param1;
|
||||
this.applySmoothingSetting();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new LoaderLoadTrait(param2,param1);
|
||||
}
|
||||
|
||||
override protected function processReadyState() : void
|
||||
{
|
||||
var _loc1_:LoaderLoadTrait = getTrait(MediaTraitType.LOAD) as LoaderLoadTrait;
|
||||
addTrait(MediaTraitType.DISPLAY_OBJECT,LoaderUtils.createDisplayObjectTrait(_loc1_.loader,this));
|
||||
this.applySmoothingSetting();
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
removeTrait(MediaTraitType.DISPLAY_OBJECT);
|
||||
}
|
||||
|
||||
private function applySmoothingSetting() : void
|
||||
{
|
||||
var _loc2_:Loader = null;
|
||||
var _loc3_:Bitmap = null;
|
||||
var _loc1_:DisplayObjectTrait = getTrait(MediaTraitType.DISPLAY_OBJECT) as DisplayObjectTrait;
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc2_ = _loc1_.displayObject as Loader;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_loc3_ = _loc2_.content as Bitmap;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.smoothing = this._smoothing;
|
||||
}
|
||||
}
|
||||
catch(error:SecurityError)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaType;
|
||||
import org.osmf.media.MediaTypeUtil;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.*;
|
||||
|
||||
public class ImageLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["image/png","image/gif","image/jpeg"]);
|
||||
|
||||
private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>([MediaType.IMAGE]);
|
||||
|
||||
private var checkPolicyFile:Boolean;
|
||||
|
||||
public function ImageLoader(param1:Boolean = true)
|
||||
{
|
||||
super();
|
||||
this.checkPolicyFile = param1;
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc4_:URL = null;
|
||||
var _loc2_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,MEDIA_TYPES_SUPPORTED,MIME_TYPES_SUPPORTED);
|
||||
if(_loc2_ != MediaTypeUtil.METADATA_MATCH_UNKNOWN)
|
||||
{
|
||||
return _loc2_ == MediaTypeUtil.METADATA_MATCH_FOUND;
|
||||
}
|
||||
var _loc3_:URLResource = param1 as URLResource;
|
||||
if(_loc3_ != null && _loc3_.url != null)
|
||||
{
|
||||
_loc4_ = new URL(_loc3_.url);
|
||||
return _loc4_.path.search(/\.gif$|\.jpg$|\.png$/i) != -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.loadLoadTrait(param1,updateLoadTrait,false,this.checkPolicyFile);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.unloadLoadTrait(param1,updateLoadTrait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.events.DRMErrorEvent;
|
||||
import flash.events.DRMStatusEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.StatusEvent;
|
||||
import flash.media.Video;
|
||||
import flash.net.NetStream;
|
||||
import flash.system.SystemUpdater;
|
||||
import flash.system.SystemUpdaterType;
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.events.DRMEvent;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.events.TimeEvent;
|
||||
import org.osmf.media.DefaultTraitResolver;
|
||||
import org.osmf.media.LoadableElementBase;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.CuePoint;
|
||||
import org.osmf.metadata.TimelineMetadata;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.ModifiableTimeTrait;
|
||||
import org.osmf.net.NetClient;
|
||||
import org.osmf.net.NetConnectionCodes;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.NetStreamAudioTrait;
|
||||
import org.osmf.net.NetStreamBufferTrait;
|
||||
import org.osmf.net.NetStreamCodes;
|
||||
import org.osmf.net.NetStreamDisplayObjectTrait;
|
||||
import org.osmf.net.NetStreamDynamicStreamTrait;
|
||||
import org.osmf.net.NetStreamLoadTrait;
|
||||
import org.osmf.net.NetStreamPlayTrait;
|
||||
import org.osmf.net.NetStreamSeekTrait;
|
||||
import org.osmf.net.NetStreamTimeTrait;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamType;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
import org.osmf.net.drm.NetStreamDRMTrait;
|
||||
import org.osmf.traits.DRMState;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class LightweightVideoElement extends LoadableElementBase
|
||||
{
|
||||
|
||||
private static const DRM_STATUS_CODE:String = "DRM.encryptedFLV";
|
||||
|
||||
private static const DRM_NEEDS_AUTHENTICATION:int = 3330;
|
||||
|
||||
private var displayObjectTrait:DisplayObjectTrait;
|
||||
|
||||
private var defaultTimeTrait:ModifiableTimeTrait;
|
||||
|
||||
private var stream:NetStream;
|
||||
|
||||
private var video:Video;
|
||||
|
||||
private var embeddedCuePoints:TimelineMetadata;
|
||||
|
||||
private var _smoothing:Boolean;
|
||||
|
||||
private var _deblocking:int;
|
||||
|
||||
private var drmTrait:NetStreamDRMTrait;
|
||||
|
||||
public function LightweightVideoElement(param1:MediaResourceBase = null, param2:NetLoader = null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new NetLoader();
|
||||
}
|
||||
super(param1,param2);
|
||||
if(!(param1 == null || param1 is URLResource))
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
public function get client() : NetClient
|
||||
{
|
||||
return this.stream != null ? this.stream.client as NetClient : null;
|
||||
}
|
||||
|
||||
public function get defaultDuration() : Number
|
||||
{
|
||||
return this.defaultTimeTrait ? this.defaultTimeTrait.duration : NaN;
|
||||
}
|
||||
|
||||
public function set defaultDuration(param1:Number) : void
|
||||
{
|
||||
if(isNaN(param1) || param1 < 0)
|
||||
{
|
||||
if(this.defaultTimeTrait != null)
|
||||
{
|
||||
removeTraitResolver(MediaTraitType.TIME);
|
||||
this.defaultTimeTrait = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.defaultTimeTrait == null)
|
||||
{
|
||||
this.defaultTimeTrait = new ModifiableTimeTrait();
|
||||
addTraitResolver(MediaTraitType.TIME,new DefaultTraitResolver(MediaTraitType.TIME,this.defaultTimeTrait));
|
||||
}
|
||||
this.defaultTimeTrait.duration = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get smoothing() : Boolean
|
||||
{
|
||||
return this._smoothing;
|
||||
}
|
||||
|
||||
public function set smoothing(param1:Boolean) : void
|
||||
{
|
||||
this._smoothing = param1;
|
||||
if(this.video != null)
|
||||
{
|
||||
this.video.smoothing = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get deblocking() : int
|
||||
{
|
||||
return this._deblocking;
|
||||
}
|
||||
|
||||
public function set deblocking(param1:int) : void
|
||||
{
|
||||
this._deblocking = param1;
|
||||
if(this.video != null)
|
||||
{
|
||||
this.video.deblocking = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get currentFPS() : Number
|
||||
{
|
||||
return this.stream != null ? this.stream.currentFPS : 0;
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new NetStreamLoadTrait(param2,param1);
|
||||
}
|
||||
|
||||
protected function createVideo() : Video
|
||||
{
|
||||
return new Video();
|
||||
}
|
||||
|
||||
override protected function processReadyState() : void
|
||||
{
|
||||
var _loc2_:StreamingURLResource = null;
|
||||
var _loc3_:ByteArray = null;
|
||||
var _loc1_:NetStreamLoadTrait = getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
|
||||
this.stream = _loc1_.netStream;
|
||||
this.video = this.createVideo();
|
||||
this.video.smoothing = this._smoothing;
|
||||
this.video.deblocking = this._deblocking;
|
||||
this.video.width = this.video.height = 0;
|
||||
this.video.attachNetStream(this.stream);
|
||||
NetClient(this.stream.client).addHandler(NetStreamCodes.ON_META_DATA,this.onMetaData);
|
||||
NetClient(this.stream.client).addHandler(NetStreamCodes.ON_CUE_POINT,this.onCuePoint);
|
||||
this.stream.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
_loc1_.connection.addEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent,false,0,true);
|
||||
this.stream.addEventListener(DRMErrorEvent.DRM_ERROR,this.onDRMErrorEvent);
|
||||
_loc2_ = resource as StreamingURLResource;
|
||||
if(_loc2_ != null && Boolean(_loc2_.drmContentData))
|
||||
{
|
||||
_loc3_ = _loc2_.drmContentData;
|
||||
this.setupDRMTrait(_loc3_);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stream.addEventListener(StatusEvent.STATUS,this.onStatus);
|
||||
this.stream.addEventListener(DRMStatusEvent.DRM_STATUS,this.onDRMStatus);
|
||||
}
|
||||
this.finishLoad();
|
||||
}
|
||||
|
||||
private function finishLoad() : void
|
||||
{
|
||||
var reconnectStreams:Boolean;
|
||||
var dsResource:DynamicStreamingResource;
|
||||
var trait:MediaTraitBase = null;
|
||||
var timeTrait:TimeTrait = null;
|
||||
var onDurationChange:Function = null;
|
||||
var dsTrait:MediaTraitBase = null;
|
||||
var loadTrait:NetStreamLoadTrait = getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
|
||||
trait = loadTrait.getTrait(MediaTraitType.DVR);
|
||||
if(trait != null)
|
||||
{
|
||||
addTrait(MediaTraitType.DVR,trait);
|
||||
}
|
||||
trait = loadTrait.getTrait(MediaTraitType.AUDIO);
|
||||
addTrait(MediaTraitType.AUDIO,trait || new NetStreamAudioTrait(this.stream));
|
||||
trait = loadTrait.getTrait(MediaTraitType.BUFFER);
|
||||
addTrait(MediaTraitType.BUFFER,trait || new NetStreamBufferTrait(this.stream));
|
||||
timeTrait = (trait = loadTrait.getTrait(MediaTraitType.TIME)) as TimeTrait;
|
||||
if(timeTrait == null)
|
||||
{
|
||||
timeTrait = new NetStreamTimeTrait(this.stream,loadTrait.resource,this.defaultDuration);
|
||||
}
|
||||
addTrait(MediaTraitType.TIME,timeTrait);
|
||||
trait = loadTrait.getTrait(MediaTraitType.DISPLAY_OBJECT);
|
||||
addTrait(MediaTraitType.DISPLAY_OBJECT,trait || new NetStreamDisplayObjectTrait(this.stream,this.video,NaN,NaN));
|
||||
trait = loadTrait.getTrait(MediaTraitType.PLAY);
|
||||
reconnectStreams = false;
|
||||
reconnectStreams = (loader as NetLoader).reconnectStreams;
|
||||
addTrait(MediaTraitType.PLAY,trait || new NetStreamPlayTrait(this.stream,resource,reconnectStreams,loadTrait.connection));
|
||||
trait = loadTrait.getTrait(MediaTraitType.SEEK);
|
||||
if(trait == null && NetStreamUtils.getStreamType(resource) != StreamType.LIVE)
|
||||
{
|
||||
trait = new NetStreamSeekTrait(timeTrait,loadTrait,this.stream,this.video);
|
||||
}
|
||||
if(trait != null)
|
||||
{
|
||||
if(isNaN(timeTrait.duration) || timeTrait.duration == 0)
|
||||
{
|
||||
onDurationChange = function(param1:TimeEvent):void
|
||||
{
|
||||
timeTrait.removeEventListener(TimeEvent.DURATION_CHANGE,onDurationChange);
|
||||
addTrait(MediaTraitType.SEEK,trait);
|
||||
};
|
||||
timeTrait.addEventListener(TimeEvent.DURATION_CHANGE,onDurationChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
addTrait(MediaTraitType.SEEK,trait);
|
||||
}
|
||||
}
|
||||
dsResource = resource as DynamicStreamingResource;
|
||||
if(dsResource != null && loadTrait.switchManager != null)
|
||||
{
|
||||
dsTrait = loadTrait.getTrait(MediaTraitType.DYNAMIC_STREAM);
|
||||
addTrait(MediaTraitType.DYNAMIC_STREAM,dsTrait || new NetStreamDynamicStreamTrait(this.stream,loadTrait.switchManager,dsResource));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
var _loc1_:NetStreamLoadTrait = getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
|
||||
NetClient(this.stream.client).removeHandler(NetStreamCodes.ON_META_DATA,this.onMetaData);
|
||||
this.stream.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
_loc1_.connection.removeEventListener(NetStatusEvent.NET_STATUS,this.onNetStatusEvent);
|
||||
removeTrait(MediaTraitType.AUDIO);
|
||||
removeTrait(MediaTraitType.BUFFER);
|
||||
removeTrait(MediaTraitType.PLAY);
|
||||
removeTrait(MediaTraitType.TIME);
|
||||
removeTrait(MediaTraitType.DISPLAY_OBJECT);
|
||||
removeTrait(MediaTraitType.SEEK);
|
||||
removeTrait(MediaTraitType.DYNAMIC_STREAM);
|
||||
removeTrait(MediaTraitType.DVR);
|
||||
this.stream.removeEventListener(DRMErrorEvent.DRM_ERROR,this.onDRMErrorEvent);
|
||||
this.stream.removeEventListener(DRMStatusEvent.DRM_STATUS,this.onDRMStatus);
|
||||
this.stream.removeEventListener(StatusEvent.STATUS,this.onStatus);
|
||||
if(this.drmTrait != null)
|
||||
{
|
||||
this.drmTrait.removeEventListener(DRMEvent.DRM_STATE_CHANGE,this.reloadAfterAuth);
|
||||
removeTrait(MediaTraitType.DRM);
|
||||
this.drmTrait = null;
|
||||
}
|
||||
this.video.attachNetStream(null);
|
||||
this.stream = null;
|
||||
this.video = null;
|
||||
this.displayObjectTrait = null;
|
||||
}
|
||||
|
||||
private function onMetaData(param1:Object) : void
|
||||
{
|
||||
var _loc3_:TimelineMetadata = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:CuePoint = null;
|
||||
var _loc2_:Array = param1.cuePoints;
|
||||
if(_loc2_ != null && _loc2_.length > 0)
|
||||
{
|
||||
_loc3_ = getMetadata(CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE) as TimelineMetadata;
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
_loc3_ = new TimelineMetadata(this);
|
||||
addMetadata(CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE,_loc3_);
|
||||
}
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc2_.length)
|
||||
{
|
||||
_loc5_ = new CuePoint(_loc2_[_loc4_].type,_loc2_[_loc4_].time,_loc2_[_loc4_].name,_loc2_[_loc4_].parameters);
|
||||
try
|
||||
{
|
||||
_loc3_.addMarker(_loc5_);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onCuePoint(param1:Object) : void
|
||||
{
|
||||
if(this.embeddedCuePoints == null)
|
||||
{
|
||||
this.embeddedCuePoints = new TimelineMetadata(this);
|
||||
addMetadata(CuePoint.EMBEDDED_CUEPOINTS_NAMESPACE,this.embeddedCuePoints);
|
||||
}
|
||||
var _loc2_:CuePoint = new CuePoint(param1.type,param1.time,param1.name,param1.parameters);
|
||||
try
|
||||
{
|
||||
this.embeddedCuePoints.addMarker(_loc2_);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private function onUpdateComplete(param1:Event) : void
|
||||
{
|
||||
(getTrait(MediaTraitType.LOAD) as LoadTrait).unload();
|
||||
(getTrait(MediaTraitType.LOAD) as LoadTrait).load();
|
||||
}
|
||||
|
||||
private function onNetStatusEvent(param1:NetStatusEvent) : void
|
||||
{
|
||||
var _loc2_:MediaError = null;
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FAILED:
|
||||
case NetStreamCodes.NETSTREAM_FAILED:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_PLAY_FAILED,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_STREAMNOTFOUND:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_STREAM_NOT_FOUND,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_FILESTRUCTUREINVALID:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_FILE_STRUCTURE_INVALID,param1.info.description);
|
||||
break;
|
||||
case NetStreamCodes.NETSTREAM_PLAY_NOSUPPORTEDTRACKFOUND:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETSTREAM_NO_SUPPORTED_TRACK_FOUND,param1.info.description);
|
||||
break;
|
||||
case NetConnectionCodes.CONNECT_IDLE_TIME_OUT:
|
||||
_loc2_ = new MediaError(MediaErrorCodes.NETCONNECTION_TIMEOUT,param1.info.description);
|
||||
}
|
||||
if(param1.info.code == NetStreamCodes.NETSTREAM_DRM_UPDATE)
|
||||
{
|
||||
this.update(SystemUpdaterType.DRM);
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function onStatus(param1:StatusEvent) : void
|
||||
{
|
||||
if(param1.code == DRM_STATUS_CODE && getTrait(MediaTraitType.DRM) == null)
|
||||
{
|
||||
this.createDRMTrait();
|
||||
}
|
||||
}
|
||||
|
||||
private function onDRMStatus(param1:DRMStatusEvent) : void
|
||||
{
|
||||
this.drmTrait.inlineOnVoucher(param1);
|
||||
}
|
||||
|
||||
private function reloadAfterAuth(param1:DRMEvent) : void
|
||||
{
|
||||
var _loc2_:NetStreamLoadTrait = null;
|
||||
if(this.drmTrait.drmState == DRMState.AUTHENTICATION_COMPLETE)
|
||||
{
|
||||
_loc2_ = getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
|
||||
if(_loc2_.loadState == LoadState.READY)
|
||||
{
|
||||
_loc2_.unload();
|
||||
}
|
||||
_loc2_.load();
|
||||
}
|
||||
}
|
||||
|
||||
private function createDRMTrait() : void
|
||||
{
|
||||
this.drmTrait = new NetStreamDRMTrait();
|
||||
addTrait(MediaTraitType.DRM,this.drmTrait);
|
||||
}
|
||||
|
||||
private function setupDRMTrait(param1:ByteArray) : void
|
||||
{
|
||||
this.createDRMTrait();
|
||||
this.drmTrait.drmMetadata = param1;
|
||||
}
|
||||
|
||||
private function onDRMErrorEvent(param1:DRMErrorEvent) : void
|
||||
{
|
||||
if(param1.errorID == DRM_NEEDS_AUTHENTICATION)
|
||||
{
|
||||
this.drmTrait.addEventListener(DRMEvent.DRM_STATE_CHANGE,this.reloadAfterAuth);
|
||||
this.drmTrait.drmMetadata = param1.contentData;
|
||||
}
|
||||
else if(param1.drmUpdateNeeded)
|
||||
{
|
||||
this.update(SystemUpdaterType.DRM);
|
||||
}
|
||||
else if(param1.systemUpdateNeeded)
|
||||
{
|
||||
this.update(SystemUpdaterType.SYSTEM);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drmTrait.inlineDRMFailed(new MediaError(param1.errorID));
|
||||
}
|
||||
}
|
||||
|
||||
private function update(param1:String) : void
|
||||
{
|
||||
if(this.drmTrait == null)
|
||||
{
|
||||
this.createDRMTrait();
|
||||
}
|
||||
var _loc2_:SystemUpdater = this.drmTrait.update(param1);
|
||||
_loc2_.addEventListener(Event.COMPLETE,this.onUpdateComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.elements.proxyClasses.LoadFromDocumentLoadTrait;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class LoadFromDocumentElement extends ProxyElement
|
||||
{
|
||||
|
||||
private var _resource:MediaResourceBase;
|
||||
|
||||
private var loadTrait:LoadFromDocumentLoadTrait;
|
||||
|
||||
private var loader:LoaderBase;
|
||||
|
||||
public function LoadFromDocumentElement(param1:MediaResourceBase = null, param2:LoaderBase = null)
|
||||
{
|
||||
super(null);
|
||||
this.loader = param2;
|
||||
this.resource = param1;
|
||||
if(param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.NULL_PARAM));
|
||||
}
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
if(this._resource != param1 && param1 != null)
|
||||
{
|
||||
this._resource = param1;
|
||||
this.loadTrait = new LoadFromDocumentLoadTrait(this.loader,this.resource);
|
||||
this.loadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE,this.onLoadStateChange,false,int.MAX_VALUE);
|
||||
if(super.getTrait(MediaTraitType.LOAD) != null)
|
||||
{
|
||||
super.removeTrait(MediaTraitType.LOAD);
|
||||
}
|
||||
super.addTrait(MediaTraitType.LOAD,this.loadTrait);
|
||||
}
|
||||
}
|
||||
|
||||
override public function get resource() : MediaResourceBase
|
||||
{
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
private function onLoaderStateChange(param1:Event) : void
|
||||
{
|
||||
removeTrait(MediaTraitType.LOAD);
|
||||
proxiedElement = this.loadTrait.mediaElement;
|
||||
}
|
||||
|
||||
private function onLoadStateChange(param1:LoadEvent) : void
|
||||
{
|
||||
var proxiedLoadTrait:LoadTrait = null;
|
||||
var onProxiedElementLoadStateChange:Function = null;
|
||||
var event:LoadEvent = param1;
|
||||
if(event.loadState == LoadState.READY)
|
||||
{
|
||||
onProxiedElementLoadStateChange = function(param1:LoadEvent):void
|
||||
{
|
||||
if(param1.loadState == LoadState.LOADING)
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
}
|
||||
else
|
||||
{
|
||||
proxiedLoadTrait.removeEventListener(LoadEvent.LOAD_STATE_CHANGE,onProxiedElementLoadStateChange);
|
||||
}
|
||||
};
|
||||
event.stopImmediatePropagation();
|
||||
removeTrait(MediaTraitType.LOAD);
|
||||
proxiedLoadTrait = this.loadTrait.mediaElement.getTrait(MediaTraitType.LOAD) as LoadTrait;
|
||||
proxiedLoadTrait.addEventListener(LoadEvent.LOAD_STATE_CHANGE,onProxiedElementLoadStateChange,false,int.MAX_VALUE);
|
||||
proxiedElement = this.loadTrait.mediaElement;
|
||||
if(proxiedLoadTrait.loadState == LoadState.UNINITIALIZED)
|
||||
{
|
||||
proxiedLoadTrait.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.proxyClasses.ProxyMetadata;
|
||||
import org.osmf.events.ContainerChangeEvent;
|
||||
import org.osmf.events.MediaElementEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class ProxyElement extends MediaElement
|
||||
{
|
||||
|
||||
private var _proxiedMetadata:ProxyMetadata;
|
||||
|
||||
private var _proxiedElement:MediaElement;
|
||||
|
||||
private var _blockedTraits:Vector.<String>;
|
||||
|
||||
public function ProxyElement(param1:MediaElement = null)
|
||||
{
|
||||
super();
|
||||
this.addEventListener(MediaElementEvent.TRAIT_ADD,this.onProxyTraitAdd,false,int.MAX_VALUE);
|
||||
this.addEventListener(MediaElementEvent.TRAIT_REMOVE,this.onProxyTraitRemove,false,int.MAX_VALUE);
|
||||
this.addEventListener(ContainerChangeEvent.CONTAINER_CHANGE,this.onProxyContainerChange);
|
||||
this.proxiedElement = param1;
|
||||
}
|
||||
|
||||
public function get proxiedElement() : MediaElement
|
||||
{
|
||||
return this._proxiedElement;
|
||||
}
|
||||
|
||||
public function set proxiedElement(param1:MediaElement) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
if(param1 != this._proxiedElement)
|
||||
{
|
||||
if(this._proxiedElement != null)
|
||||
{
|
||||
this.toggleMediaElementListeners(this._proxiedElement,false);
|
||||
for each(_loc2_ in this._proxiedElement.traitTypes)
|
||||
{
|
||||
if(super.hasTrait(_loc2_) == false && (this._blockedTraits == null || this._blockedTraits.indexOf(_loc2_) == -1))
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_REMOVE,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
this._proxiedElement = param1;
|
||||
if(this._proxiedElement != null)
|
||||
{
|
||||
ProxyMetadata(metadata).metadata = this._proxiedElement.metadata;
|
||||
this._proxiedElement.dispatchEvent(new ContainerChangeEvent(ContainerChangeEvent.CONTAINER_CHANGE,false,false,this._proxiedElement.container,container));
|
||||
this.toggleMediaElementListeners(this._proxiedElement,true);
|
||||
for each(_loc2_ in this._proxiedElement.traitTypes)
|
||||
{
|
||||
if(super.hasTrait(_loc2_) == false && (this._blockedTraits == null || this._blockedTraits.indexOf(_loc2_) == -1))
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_ADD,false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function get traitTypes() : Vector.<String>
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc1_:Vector.<String> = new Vector.<String>();
|
||||
for each(_loc2_ in MediaTraitType.ALL_TYPES)
|
||||
{
|
||||
if(this.hasTrait(_loc2_))
|
||||
{
|
||||
_loc1_.push(_loc2_);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function hasTrait(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
return this.getTrait(param1) != null;
|
||||
}
|
||||
|
||||
override public function getTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.INVALID_PARAM));
|
||||
}
|
||||
var _loc2_:MediaTraitBase = null;
|
||||
if(this.blocksTrait(param1) == false)
|
||||
{
|
||||
_loc2_ = super.getTrait(param1) || (this.proxiedElement != null ? this.proxiedElement.getTrait(param1) : null);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override public function get resource() : MediaResourceBase
|
||||
{
|
||||
return this.proxiedElement ? this.proxiedElement.resource : null;
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
if(this.proxiedElement != null)
|
||||
{
|
||||
this.proxiedElement.resource = param1;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function addTrait(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(this.blocksTrait(param1) == false && this.proxiedElement != null && this.proxiedElement.hasTrait(param1) == true)
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_REMOVE,false,false,param1));
|
||||
}
|
||||
super.addTrait(param1,param2);
|
||||
}
|
||||
|
||||
override protected function removeTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
var _loc2_:MediaTraitBase = super.removeTrait(param1);
|
||||
if(this.blocksTrait(param1) == false && this.proxiedElement != null && this.proxiedElement.hasTrait(param1) == true)
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_ADD,false,false,param1));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function createMetadata() : Metadata
|
||||
{
|
||||
return new ProxyMetadata();
|
||||
}
|
||||
|
||||
final protected function get blockedTraits() : Vector.<String>
|
||||
{
|
||||
if(this._blockedTraits == null)
|
||||
{
|
||||
this._blockedTraits = new Vector.<String>();
|
||||
}
|
||||
return this._blockedTraits;
|
||||
}
|
||||
|
||||
final protected function set blockedTraits(param1:Vector.<String>) : void
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
if(param1 == this._blockedTraits)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc2_:Array = [];
|
||||
var _loc3_:Array = [];
|
||||
if(this._proxiedElement != null)
|
||||
{
|
||||
for each(_loc4_ in MediaTraitType.ALL_TYPES)
|
||||
{
|
||||
if(param1.indexOf(_loc4_) != -1)
|
||||
{
|
||||
if(this._blockedTraits == null || this._blockedTraits.indexOf(_loc4_) == -1)
|
||||
{
|
||||
_loc2_.push(_loc4_);
|
||||
}
|
||||
}
|
||||
else if(this._blockedTraits != null && this._blockedTraits.indexOf(_loc4_) != -1)
|
||||
{
|
||||
_loc3_.push(_loc4_);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this._proxiedElement != null)
|
||||
{
|
||||
for each(_loc4_ in _loc2_)
|
||||
{
|
||||
if(this.proxiedElement.hasTrait(_loc4_) || Boolean(super.hasTrait(_loc4_)))
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_REMOVE,false,false,_loc4_));
|
||||
}
|
||||
}
|
||||
this._blockedTraits = param1;
|
||||
for each(_loc4_ in _loc3_)
|
||||
{
|
||||
if(this.proxiedElement.hasTrait(_loc4_) || Boolean(super.hasTrait(_loc4_)))
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent(MediaElementEvent.TRAIT_ADD,false,false,_loc4_));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._blockedTraits = param1;
|
||||
}
|
||||
}
|
||||
|
||||
private function toggleMediaElementListeners(param1:MediaElement, param2:Boolean) : void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
this._proxiedElement.addEventListener(MediaErrorEvent.MEDIA_ERROR,this.onMediaError);
|
||||
this._proxiedElement.addEventListener(MediaElementEvent.TRAIT_ADD,this.onTraitAdd);
|
||||
this._proxiedElement.addEventListener(MediaElementEvent.TRAIT_REMOVE,this.onTraitRemove);
|
||||
this._proxiedElement.addEventListener(MediaElementEvent.METADATA_ADD,this.onMetadataEvent);
|
||||
this._proxiedElement.addEventListener(MediaElementEvent.METADATA_REMOVE,this.onMetadataEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._proxiedElement.removeEventListener(MediaErrorEvent.MEDIA_ERROR,this.onMediaError);
|
||||
this._proxiedElement.removeEventListener(MediaElementEvent.TRAIT_ADD,this.onTraitAdd);
|
||||
this._proxiedElement.removeEventListener(MediaElementEvent.TRAIT_REMOVE,this.onTraitRemove);
|
||||
this._proxiedElement.removeEventListener(MediaElementEvent.METADATA_ADD,this.onMetadataEvent);
|
||||
this._proxiedElement.removeEventListener(MediaElementEvent.METADATA_REMOVE,this.onMetadataEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaError(param1:MediaErrorEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onTraitAdd(param1:MediaElementEvent) : void
|
||||
{
|
||||
this.processTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onTraitRemove(param1:MediaElementEvent) : void
|
||||
{
|
||||
this.processTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onMetadataEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onProxyContainerChange(param1:ContainerChangeEvent) : void
|
||||
{
|
||||
if(this.proxiedElement != null)
|
||||
{
|
||||
this.proxiedElement.dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
private function onProxyTraitAdd(param1:MediaElementEvent) : void
|
||||
{
|
||||
this.processProxyTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onProxyTraitRemove(param1:MediaElementEvent) : void
|
||||
{
|
||||
this.processProxyTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function processTraitsChangeEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(this.blocksTrait(param1.traitType) == false && super.hasTrait(param1.traitType) == false)
|
||||
{
|
||||
super.dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
private function processProxyTraitsChangeEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(this.blocksTrait(param1.traitType) == true)
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
private function blocksTrait(param1:String) : Boolean
|
||||
{
|
||||
return Boolean(this._blockedTraits) && this._blockedTraits.indexOf(param1) != -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.loaderClasses.LoaderLoadTrait;
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.LoadableElementBase;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitType;
|
||||
|
||||
public class SWFElement extends LoadableElementBase
|
||||
{
|
||||
|
||||
public function SWFElement(param1:URLResource = null, param2:SWFLoader = null)
|
||||
{
|
||||
if(param2 == null)
|
||||
{
|
||||
param2 = new SWFLoader();
|
||||
}
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new LoaderLoadTrait(param2,param1);
|
||||
}
|
||||
|
||||
override protected function processReadyState() : void
|
||||
{
|
||||
var _loc1_:LoaderLoadTrait = getTrait(MediaTraitType.LOAD) as LoaderLoadTrait;
|
||||
addTrait(MediaTraitType.DISPLAY_OBJECT,LoaderUtils.createDisplayObjectTrait(_loc1_.loader,this));
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
removeTrait(MediaTraitType.DISPLAY_OBJECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaType;
|
||||
import org.osmf.media.MediaTypeUtil;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class SWFLoader extends LoaderBase
|
||||
{
|
||||
|
||||
public static var allowValidationOfLoadedContent:Boolean = true;
|
||||
|
||||
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["application/x-shockwave-flash"]);
|
||||
|
||||
private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>([MediaType.SWF]);
|
||||
|
||||
private var useCurrentSecurityDomain:Boolean = false;
|
||||
|
||||
private var _validateLoadedContentFunction:Function = null;
|
||||
|
||||
public function SWFLoader(param1:Boolean = false)
|
||||
{
|
||||
super();
|
||||
this.useCurrentSecurityDomain = param1;
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc4_:URL = null;
|
||||
var _loc2_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,MEDIA_TYPES_SUPPORTED,MIME_TYPES_SUPPORTED);
|
||||
if(_loc2_ != MediaTypeUtil.METADATA_MATCH_UNKNOWN)
|
||||
{
|
||||
return _loc2_ == MediaTypeUtil.METADATA_MATCH_FOUND;
|
||||
}
|
||||
var _loc3_:URLResource = param1 as URLResource;
|
||||
if(_loc3_ != null && _loc3_.url != null)
|
||||
{
|
||||
_loc4_ = new URL(_loc3_.url);
|
||||
return _loc4_.path.search(/\.swf$/i) != -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.loadLoadTrait(param1,updateLoadTrait,this.useCurrentSecurityDomain,false,this.validateLoadedContentFunction);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.unloadLoadTrait(param1,updateLoadTrait);
|
||||
}
|
||||
|
||||
public function get validateLoadedContentFunction() : Function
|
||||
{
|
||||
return allowValidationOfLoadedContent ? this._validateLoadedContentFunction : null;
|
||||
}
|
||||
|
||||
public function set validateLoadedContentFunction(param1:Function) : void
|
||||
{
|
||||
this._validateLoadedContentFunction = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.errors.IOError;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.media.Sound;
|
||||
import flash.media.SoundLoaderContext;
|
||||
import flash.net.URLRequest;
|
||||
import org.osmf.elements.audioClasses.SoundLoadTrait;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaType;
|
||||
import org.osmf.media.MediaTypeUtil;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.*;
|
||||
|
||||
public class SoundLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["audio/mpeg"]);
|
||||
|
||||
private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>([MediaType.AUDIO]);
|
||||
|
||||
private static const MIN_BYTES_TO_RECEIVE:int = 16;
|
||||
|
||||
private var checkPolicyFile:Boolean;
|
||||
|
||||
public function SoundLoader(param1:Boolean = false)
|
||||
{
|
||||
super();
|
||||
this.checkPolicyFile = param1;
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,MEDIA_TYPES_SUPPORTED,MIME_TYPES_SUPPORTED);
|
||||
if(_loc2_ != MediaTypeUtil.METADATA_MATCH_UNKNOWN)
|
||||
{
|
||||
return _loc2_ == MediaTypeUtil.METADATA_MATCH_FOUND;
|
||||
}
|
||||
var _loc3_:URLResource = param1 as URLResource;
|
||||
if(_loc3_ == null || _loc3_.url == null || _loc3_.url.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc4_:URL = new URL(_loc3_.url);
|
||||
if(_loc4_.protocol == "")
|
||||
{
|
||||
return _loc4_.path.search(/\.mp3$|\.m4a$/i) != -1;
|
||||
}
|
||||
if(_loc4_.protocol.search(/file$|http$|https$/i) != -1)
|
||||
{
|
||||
return _loc4_.path == null || _loc4_.path.length <= 0 || _loc4_.path.indexOf(".") == -1 || _loc4_.path.search(/\.mp3$|\.m4a$/i) != -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
var urlRequest:URLRequest;
|
||||
var context:SoundLoaderContext;
|
||||
var soundLoadTrait:SoundLoadTrait = null;
|
||||
var sound:Sound = null;
|
||||
var onProgress:Function = null;
|
||||
var onIOError:Function = null;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var toggleSoundListeners:Function = function(param1:Sound, param2:Boolean):void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.addEventListener(ProgressEvent.PROGRESS,onProgress);
|
||||
param1.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.removeEventListener(ProgressEvent.PROGRESS,onProgress);
|
||||
param1.removeEventListener(IOErrorEvent.IO_ERROR,onIOError);
|
||||
}
|
||||
};
|
||||
onProgress = function(param1:ProgressEvent):void
|
||||
{
|
||||
if(param1.bytesTotal >= MIN_BYTES_TO_RECEIVE && soundLoadTrait.loadState == LoadState.LOADING)
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
soundLoadTrait.sound = sound;
|
||||
updateLoadTrait(soundLoadTrait,LoadState.READY);
|
||||
}
|
||||
};
|
||||
onIOError = function(param1:IOErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.IO_ERROR,param1 ? param1.text : param2)));
|
||||
};
|
||||
var handleSecurityError:Function = function(param1:String):void
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
updateLoadTrait(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.SECURITY_ERROR,param1)));
|
||||
};
|
||||
soundLoadTrait = loadTrait as SoundLoadTrait;
|
||||
updateLoadTrait(soundLoadTrait,LoadState.LOADING);
|
||||
sound = new Sound();
|
||||
toggleSoundListeners(sound,true);
|
||||
urlRequest = new URLRequest((soundLoadTrait.resource as URLResource).url.toString());
|
||||
context = new SoundLoaderContext(1000,this.checkPolicyFile);
|
||||
try
|
||||
{
|
||||
sound.load(urlRequest,context);
|
||||
}
|
||||
catch(ioError:IOError)
|
||||
{
|
||||
onIOError(null,ioError.message);
|
||||
}
|
||||
catch(securityError:SecurityError)
|
||||
{
|
||||
handleSecurityError(securityError.message);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
var _loc2_:SoundLoadTrait = param1 as SoundLoadTrait;
|
||||
updateLoadTrait(_loc2_,LoadState.UNLOADING);
|
||||
try
|
||||
{
|
||||
if(_loc2_.sound != null)
|
||||
{
|
||||
_loc2_.sound.close();
|
||||
}
|
||||
}
|
||||
catch(error:IOError)
|
||||
{
|
||||
}
|
||||
updateLoadTrait(_loc2_,LoadState.UNINITIALIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingNetLoader;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class VideoElement extends LightweightVideoElement
|
||||
{
|
||||
|
||||
private var _alternateLoaders:Vector.<LoaderBase>;
|
||||
|
||||
public function VideoElement(param1:MediaResourceBase = null, param2:NetLoader = null)
|
||||
{
|
||||
super(null,null);
|
||||
super.loader = param2;
|
||||
this.resource = param1;
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
loader = getLoaderForResource(param1,this.alternateLoaders);
|
||||
super.resource = param1;
|
||||
}
|
||||
|
||||
private function get alternateLoaders() : Vector.<LoaderBase>
|
||||
{
|
||||
if(this._alternateLoaders == null)
|
||||
{
|
||||
this._alternateLoaders = new Vector.<LoaderBase>();
|
||||
this._alternateLoaders.push(new HTTPStreamingNetLoader());
|
||||
this._alternateLoaders.push(new RTMPDynamicStreamingNetLoader());
|
||||
this._alternateLoaders.push(new NetLoader());
|
||||
}
|
||||
return this._alternateLoaders;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.media.SoundTransform;
|
||||
import org.osmf.traits.AudioTrait;
|
||||
|
||||
public class AudioAudioTrait extends AudioTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioAudioTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.soundTransform.volume = volume;
|
||||
param1.soundTransform.pan = pan;
|
||||
}
|
||||
|
||||
override protected function volumeChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.volume = muted ? 0 : param1;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function mutedChangeStart(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.volume = param1 ? 0 : volume;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function panChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.pan = param1;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.traits.PlayState;
|
||||
import org.osmf.traits.PlayTrait;
|
||||
|
||||
public class AudioPlayTrait extends PlayTrait
|
||||
{
|
||||
|
||||
private var lastPlayFailed:Boolean = false;
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioPlayTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.addEventListener(Event.COMPLETE,this.onPlaybackComplete,false,1,true);
|
||||
}
|
||||
|
||||
override protected function playStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == PlayState.PLAYING)
|
||||
{
|
||||
this.lastPlayFailed = !this.soundAdapter.play();
|
||||
}
|
||||
else if(param1 == PlayState.PAUSED)
|
||||
{
|
||||
this.soundAdapter.pause();
|
||||
}
|
||||
else if(param1 == PlayState.STOPPED)
|
||||
{
|
||||
this.soundAdapter.stop();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function playStateChangeEnd() : void
|
||||
{
|
||||
if(this.lastPlayFailed)
|
||||
{
|
||||
stop();
|
||||
this.lastPlayFailed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.playStateChangeEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import org.osmf.traits.SeekTrait;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class AudioSeekTrait extends SeekTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioSeekTrait(param1:TimeTrait, param2:SoundAdapter)
|
||||
{
|
||||
super(param1);
|
||||
this.soundAdapter = param2;
|
||||
}
|
||||
|
||||
override protected function seekingChangeStart(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.soundAdapter.seek(param2);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function seekingChangeEnd(param1:Number) : void
|
||||
{
|
||||
super.seekingChangeEnd(param1);
|
||||
if(seeking == true)
|
||||
{
|
||||
setSeeking(false,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.ProgressEvent;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class AudioTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioTimeTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.addEventListener(ProgressEvent.PROGRESS,this.onDownloadProgress,false,0,true);
|
||||
param1.addEventListener(SoundAdapter.DOWNLOAD_COMPLETE,this.onDownloadComplete,false,0,true);
|
||||
param1.addEventListener(Event.COMPLETE,this.onPlaybackComplete,false,0,true);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return this.soundAdapter.currentTime;
|
||||
}
|
||||
|
||||
private function onDownloadProgress(param1:Event) : void
|
||||
{
|
||||
if(!isNaN(this.soundAdapter.estimatedDuration) && this.soundAdapter.estimatedDuration > 0)
|
||||
{
|
||||
this.soundAdapter.removeEventListener(ProgressEvent.PROGRESS,this.onDownloadProgress);
|
||||
setDuration(this.soundAdapter.estimatedDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
setDuration(this.soundAdapter.estimatedDuration);
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.media.Sound;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
|
||||
public class SoundAdapter extends EventDispatcher
|
||||
{
|
||||
|
||||
public static const DOWNLOAD_COMPLETE:String = "downloadComplete";
|
||||
|
||||
private var owner:MediaElement;
|
||||
|
||||
private var _soundTransform:SoundTransform;
|
||||
|
||||
private var sound:Sound;
|
||||
|
||||
private var playing:Boolean = false;
|
||||
|
||||
private var channel:SoundChannel;
|
||||
|
||||
private var lastStartTime:Number = 0;
|
||||
|
||||
public function SoundAdapter(param1:MediaElement, param2:Sound)
|
||||
{
|
||||
super();
|
||||
this.owner = param1;
|
||||
this.sound = param2;
|
||||
this._soundTransform = new SoundTransform();
|
||||
param2.addEventListener(Event.COMPLETE,this.onDownloadComplete,false,0,true);
|
||||
param2.addEventListener(ProgressEvent.PROGRESS,this.onProgress,false,0,true);
|
||||
param2.addEventListener(IOErrorEvent.IO_ERROR,this.onIOError,false,0,true);
|
||||
}
|
||||
|
||||
public function get currentTime() : Number
|
||||
{
|
||||
return this.channel != null ? this.channel.position / 1000 : this.lastStartTime / 1000;
|
||||
}
|
||||
|
||||
public function get estimatedDuration() : Number
|
||||
{
|
||||
return this.sound.length / (1000 * this.sound.bytesLoaded / this.sound.bytesTotal);
|
||||
}
|
||||
|
||||
public function get soundTransform() : SoundTransform
|
||||
{
|
||||
return this._soundTransform;
|
||||
}
|
||||
|
||||
public function set soundTransform(param1:SoundTransform) : void
|
||||
{
|
||||
this._soundTransform = param1;
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.channel.soundTransform = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function play(param1:Number = -1) : Boolean
|
||||
{
|
||||
var time:Number = param1;
|
||||
var success:Boolean = false;
|
||||
if(this.channel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.channel = this.sound.play(time != -1 ? time : this.lastStartTime);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
channel = null;
|
||||
}
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.playing = true;
|
||||
this.channel.soundTransform = this._soundTransform;
|
||||
this.channel.addEventListener(Event.SOUND_COMPLETE,this.onSoundComplete);
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.owner.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.SOUND_PLAY_FAILED)));
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.lastStartTime = this.channel.position;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.lastStartTime = 0;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function seek(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Boolean = this.playing;
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.clearChannel();
|
||||
}
|
||||
this.play(param1 * 1000);
|
||||
if(_loc2_ == false)
|
||||
{
|
||||
this.pause();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearChannel() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.channel.removeEventListener(Event.SOUND_COMPLETE,this.onSoundComplete);
|
||||
this.channel.stop();
|
||||
this.channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSoundComplete(param1:Event) : void
|
||||
{
|
||||
this.lastStartTime = this.channel.position;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(new Event(DOWNLOAD_COMPLETE));
|
||||
}
|
||||
|
||||
private function onProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
this.owner.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.IO_ERROR)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.media.Sound;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class SoundLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var lastBytesTotal:Number;
|
||||
|
||||
private var _sound:Sound;
|
||||
|
||||
public function SoundLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get sound() : Sound
|
||||
{
|
||||
return this._sound;
|
||||
}
|
||||
|
||||
public function set sound(param1:Sound) : void
|
||||
{
|
||||
this._sound = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == LoadState.READY)
|
||||
{
|
||||
if(this._sound != null)
|
||||
{
|
||||
this._sound.addEventListener(Event.OPEN,this.bytesTotalCheckingHandler,false,0,true);
|
||||
this._sound.addEventListener(ProgressEvent.PROGRESS,this.bytesTotalCheckingHandler,false,0,true);
|
||||
}
|
||||
}
|
||||
else if(param1 == LoadState.UNINITIALIZED)
|
||||
{
|
||||
this._sound = null;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get bytesLoaded() : Number
|
||||
{
|
||||
return this._sound ? this._sound.bytesLoaded : NaN;
|
||||
}
|
||||
|
||||
override public function get bytesTotal() : Number
|
||||
{
|
||||
return this._sound ? this._sound.bytesTotal : NaN;
|
||||
}
|
||||
|
||||
private function bytesTotalCheckingHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoadEvent = null;
|
||||
if(this.lastBytesTotal != this._sound.bytesTotal)
|
||||
{
|
||||
_loc2_ = new LoadEvent(LoadEvent.BYTES_TOTAL_CHANGE,false,false,null,this._sound.bytesTotal);
|
||||
this.lastBytesTotal = this._sound.bytesTotal;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.osmf.elements.compositeClasses
|
||||
{
|
||||
public final class CompositionMode
|
||||
{
|
||||
|
||||
public static const PARALLEL:String = "parallel";
|
||||
|
||||
public static const SERIAL:String = "serial";
|
||||
|
||||
public function CompositionMode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class Base64Decoder
|
||||
{
|
||||
|
||||
private static const ESCAPE_CHAR_CODE:Number = 61;
|
||||
|
||||
private static const inverse:Array = [64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62,64,64,64,63,52,53,54,55,56,57,58,59,60,61,64,64,64,64,64,64,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,64,64,64,64,64,64,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64];
|
||||
|
||||
private var count:int = 0;
|
||||
|
||||
private var data:ByteArray;
|
||||
|
||||
private var filled:int = 0;
|
||||
|
||||
private var work:Array = [0,0,0,0];
|
||||
|
||||
public function Base64Decoder()
|
||||
{
|
||||
super();
|
||||
this.data = new ByteArray();
|
||||
}
|
||||
|
||||
private static function copyByteArray(param1:ByteArray, param2:ByteArray, param3:uint = 0) : void
|
||||
{
|
||||
var _loc4_:int = int(param1.position);
|
||||
param1.position = 0;
|
||||
param2.position = 0;
|
||||
var _loc5_:uint = 0;
|
||||
while(param1.bytesAvailable > 0 && _loc5_ < param3)
|
||||
{
|
||||
param2.writeByte(param1.readByte());
|
||||
_loc5_++;
|
||||
}
|
||||
param1.position = _loc4_;
|
||||
param2.position = 0;
|
||||
}
|
||||
|
||||
public function decode(param1:String) : void
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc2_:uint = 0;
|
||||
for(; _loc2_ < param1.length; _loc2_++)
|
||||
{
|
||||
_loc3_ = param1.charCodeAt(_loc2_);
|
||||
if(_loc3_ == ESCAPE_CHAR_CODE)
|
||||
{
|
||||
var _loc4_:Number;
|
||||
this.work[_loc4_ = this.count++] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inverse[_loc3_] == 64)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.work[_loc4_ = this.count++] = inverse[_loc3_];
|
||||
}
|
||||
if(this.count == 4)
|
||||
{
|
||||
this.count = 0;
|
||||
this.data.writeByte(this.work[0] << 2 | (this.work[1] & 0xFF) >> 4);
|
||||
++this.filled;
|
||||
if(this.work[2] == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.data.writeByte(this.work[1] << 4 | (this.work[2] & 0xFF) >> 2);
|
||||
++this.filled;
|
||||
if(this.work[3] == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.data.writeByte(this.work[2] << 6 | this.work[3]);
|
||||
++this.filled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function drain() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
copyByteArray(this.data,_loc1_,this.filled);
|
||||
this.filled = 0;
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class BootstrapInfo
|
||||
{
|
||||
|
||||
public var data:ByteArray;
|
||||
|
||||
public var url:String;
|
||||
|
||||
public var profile:String;
|
||||
|
||||
public var id:String;
|
||||
|
||||
public function BootstrapInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class DRMAdditionalHeader
|
||||
{
|
||||
|
||||
public var data:ByteArray;
|
||||
|
||||
public var url:String;
|
||||
|
||||
public var id:String;
|
||||
|
||||
public function DRMAdditionalHeader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
internal class DateUtil
|
||||
{
|
||||
|
||||
public function DateUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function parseW3CDTF(param1:String) : Date
|
||||
{
|
||||
var finalDate:Date = null;
|
||||
var dateStr:String = null;
|
||||
var timeStr:String = null;
|
||||
var dateArr:Array = null;
|
||||
var year:Number = NaN;
|
||||
var month:Number = NaN;
|
||||
var date:Number = NaN;
|
||||
var multiplier:Number = NaN;
|
||||
var offsetHours:Number = NaN;
|
||||
var offsetMinutes:Number = NaN;
|
||||
var offsetStr:String = null;
|
||||
var timeArr:Array = null;
|
||||
var hour:Number = NaN;
|
||||
var minutes:Number = NaN;
|
||||
var secondsArr:Array = null;
|
||||
var seconds:Number = NaN;
|
||||
var milliseconds:Number = NaN;
|
||||
var utc:Number = NaN;
|
||||
var offset:Number = NaN;
|
||||
var eStr:String = null;
|
||||
var str:String = param1;
|
||||
try
|
||||
{
|
||||
dateStr = str.substring(0,str.indexOf("T"));
|
||||
timeStr = str.substring(str.indexOf("T") + 1,str.length);
|
||||
dateArr = dateStr.split("-");
|
||||
year = Number(dateArr.shift());
|
||||
month = Number(dateArr.shift());
|
||||
date = Number(dateArr.shift());
|
||||
if(timeStr.indexOf("Z") != -1)
|
||||
{
|
||||
multiplier = 1;
|
||||
offsetHours = 0;
|
||||
offsetMinutes = 0;
|
||||
timeStr = timeStr.replace("Z","");
|
||||
}
|
||||
else if(timeStr.indexOf("+") != -1)
|
||||
{
|
||||
multiplier = 1;
|
||||
offsetStr = timeStr.substring(timeStr.indexOf("+") + 1,timeStr.length);
|
||||
offsetHours = Number(offsetStr.substring(0,offsetStr.indexOf(":")));
|
||||
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":") + 1,offsetStr.length));
|
||||
timeStr = timeStr.substring(0,timeStr.indexOf("+"));
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier = -1;
|
||||
offsetStr = timeStr.substring(timeStr.indexOf("-") + 1,timeStr.length);
|
||||
offsetHours = Number(offsetStr.substring(0,offsetStr.indexOf(":")));
|
||||
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":") + 1,offsetStr.length));
|
||||
timeStr = timeStr.substring(0,timeStr.indexOf("-"));
|
||||
}
|
||||
timeArr = timeStr.split(":");
|
||||
hour = Number(timeArr.shift());
|
||||
minutes = Number(timeArr.shift());
|
||||
secondsArr = timeArr.length > 0 ? String(timeArr.shift()).split(".") : null;
|
||||
seconds = secondsArr != null && secondsArr.length > 0 ? Number(secondsArr.shift()) : 0;
|
||||
milliseconds = secondsArr != null && secondsArr.length > 0 ? Number(secondsArr.shift()) : 0;
|
||||
utc = Date.UTC(year,month - 1,date,hour,minutes,seconds,milliseconds);
|
||||
offset = (offsetHours * 3600000 + offsetMinutes * 60000) * multiplier;
|
||||
finalDate = new Date(utc - offset);
|
||||
if(finalDate.toString() == "Invalid Date")
|
||||
{
|
||||
throw new Error("This date does not conform to W3CDTF.");
|
||||
}
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
eStr = "Unable to parse the string [" + str + "] into a date. ";
|
||||
eStr += "The internal error was: " + e.toString();
|
||||
throw new Error(eStr);
|
||||
}
|
||||
return finalDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
|
||||
public class Manifest
|
||||
{
|
||||
|
||||
public var id:String;
|
||||
|
||||
public var baseURL:String;
|
||||
|
||||
public var urlIncludesFMSApplicationInstance:Boolean = false;
|
||||
|
||||
public var duration:Number;
|
||||
|
||||
public var mimeType:String;
|
||||
|
||||
public var streamType:String;
|
||||
|
||||
public var deliveryType:String;
|
||||
|
||||
public var startTime:Date;
|
||||
|
||||
public var bootstrapInfos:Vector.<BootstrapInfo> = new Vector.<BootstrapInfo>();
|
||||
|
||||
public var drmAdditionalHeaders:Vector.<DRMAdditionalHeader> = new Vector.<DRMAdditionalHeader>();
|
||||
|
||||
public var media:Vector.<Media> = new Vector.<Media>();
|
||||
|
||||
public var dvrInfo:DVRInfo = null;
|
||||
|
||||
public function Manifest()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,597 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.MediaType;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.MetadataNamespaces;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.MulticastResource;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
import org.osmf.net.StreamType;
|
||||
import org.osmf.net.StreamingURLResource;
|
||||
import org.osmf.net.httpstreaming.dvr.DVRInfo;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
import org.osmf.utils.URL;
|
||||
|
||||
public class ManifestParser
|
||||
{
|
||||
|
||||
internal namespace xmlns = "http://ns.adobe.com/f4m/1.0";
|
||||
|
||||
public function ManifestParser()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function parse(param1:String, param2:String = null) : Manifest
|
||||
{
|
||||
var _loc7_:XML = null;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc9_:Boolean = false;
|
||||
var _loc10_:XML = null;
|
||||
var _loc11_:XML = null;
|
||||
var _loc12_:XML = null;
|
||||
var _loc13_:Media = null;
|
||||
var _loc3_:Manifest = new Manifest();
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc5_:XML = new XML(param1);
|
||||
if(_loc5_.id.length() > 0)
|
||||
{
|
||||
_loc3_.id = _loc5_.id.text();
|
||||
}
|
||||
if(_loc5_.duration.length() > 0)
|
||||
{
|
||||
_loc3_.duration = _loc5_.duration.text();
|
||||
}
|
||||
if(_loc5_.startTime.length() > 0)
|
||||
{
|
||||
_loc3_.startTime = DateUtil.parseW3CDTF(_loc5_.startTime.text());
|
||||
}
|
||||
if(_loc5_.mimeType.length() > 0)
|
||||
{
|
||||
_loc3_.mimeType = _loc5_.mimeType.text();
|
||||
}
|
||||
if(_loc5_.streamType.length() > 0)
|
||||
{
|
||||
_loc3_.streamType = _loc5_.streamType.text();
|
||||
}
|
||||
if(_loc5_.deliveryType.length() > 0)
|
||||
{
|
||||
_loc3_.deliveryType = _loc5_.deliveryType.text();
|
||||
}
|
||||
if(_loc5_.baseURL.length() > 0)
|
||||
{
|
||||
_loc3_.baseURL = _loc5_.baseURL.text();
|
||||
}
|
||||
if(_loc5_.urlIncludesFMSApplicationInstance.length() > 0)
|
||||
{
|
||||
_loc3_.urlIncludesFMSApplicationInstance = _loc5_.urlIncludesFMSApplicationInstance.text() == "true";
|
||||
}
|
||||
var _loc6_:String = _loc3_.baseURL != null ? _loc3_.baseURL : param2;
|
||||
var _loc14_:int = 0;
|
||||
var _loc15_:* = _loc5_.dvrInfo;
|
||||
for each(_loc7_ in _loc15_)
|
||||
{
|
||||
this.parseDVRInfo(_loc7_,_loc6_,_loc3_);
|
||||
}
|
||||
_loc8_ = false;
|
||||
_loc9_ = false;
|
||||
for each(_loc10_ in _loc5_.media)
|
||||
{
|
||||
_loc13_ = this.parseMedia(_loc10_,_loc6_);
|
||||
if(_loc13_.multicastGroupspec != null && _loc13_.multicastGroupspec.length > 0 && (_loc13_.multicastStreamName == null || _loc13_.multicastStreamName.length <= 0) || _loc13_.multicastStreamName != null && _loc13_.multicastStreamName.length > 0 && (_loc13_.multicastGroupspec == null || _loc13_.multicastGroupspec.length <= 0))
|
||||
{
|
||||
_loc9_ = true;
|
||||
}
|
||||
if(_loc13_.multicastGroupspec != null && _loc13_.multicastGroupspec.length > 0)
|
||||
{
|
||||
_loc4_ = true;
|
||||
}
|
||||
_loc3_.media.push(_loc13_);
|
||||
_loc8_ ||= isNaN(_loc13_.bitrate);
|
||||
}
|
||||
if(_loc9_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.MULTICAST_PARAMETER_INVALID));
|
||||
}
|
||||
if(_loc3_.media.length > 1 && _loc4_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.MULTICAST_NOT_SUPPORT_MBR));
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc3_.streamType = StreamType.LIVE;
|
||||
}
|
||||
if(_loc3_.media.length > 1 && _loc8_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.F4M_PARSE_BITRATE_MISSING));
|
||||
}
|
||||
for each(_loc11_ in _loc5_.drmAdditionalHeader)
|
||||
{
|
||||
this.parseDRMAdditionalHeader(_loc11_,_loc3_.media,_loc6_,_loc3_);
|
||||
}
|
||||
for each(_loc12_ in _loc5_.bootstrapInfo)
|
||||
{
|
||||
this.parseBootstrapInfo(_loc12_,_loc3_.media,_loc6_,_loc3_);
|
||||
}
|
||||
this.generateRTMPBaseURL(_loc3_);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function parseMedia(param1:XML, param2:String) : Media
|
||||
{
|
||||
var _loc3_:Base64Decoder = null;
|
||||
var _loc5_:ByteArray = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:Object = null;
|
||||
var _loc4_:Media = new Media();
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc4_.url = param1.@url;
|
||||
if(param1.attribute("bitrate").length() > 0)
|
||||
{
|
||||
_loc4_.bitrate = param1.@bitrate;
|
||||
}
|
||||
if(param1.attribute("drmAdditionalHeaderId").length() > 0)
|
||||
{
|
||||
_loc4_.drmAdditionalHeader.id = param1.@drmAdditionalHeaderId;
|
||||
}
|
||||
if(param1.attribute("bootstrapInfoId").length() > 0)
|
||||
{
|
||||
_loc4_.bootstrapInfo = new BootstrapInfo();
|
||||
_loc4_.bootstrapInfo.id = param1.@bootstrapInfoId;
|
||||
}
|
||||
if(param1.attribute("height").length() > 0)
|
||||
{
|
||||
_loc4_.height = param1.@height;
|
||||
}
|
||||
if(param1.attribute("width").length() > 0)
|
||||
{
|
||||
_loc4_.width = param1.@width;
|
||||
}
|
||||
if(param1.attribute("groupspec").length() > 0)
|
||||
{
|
||||
_loc4_.multicastGroupspec = param1.@groupspec;
|
||||
}
|
||||
if(param1.attribute("multicastStreamName").length() > 0)
|
||||
{
|
||||
_loc4_.multicastStreamName = param1.@multicastStreamName;
|
||||
}
|
||||
if(param1.moov.length() > 0)
|
||||
{
|
||||
_loc3_ = new Base64Decoder();
|
||||
_loc3_.decode(param1.moov.text());
|
||||
_loc4_.moov = _loc3_.drain();
|
||||
}
|
||||
if(param1.metadata.length() > 0)
|
||||
{
|
||||
_loc3_ = new Base64Decoder();
|
||||
_loc3_.decode(param1.metadata.text());
|
||||
_loc5_ = _loc3_.drain();
|
||||
_loc5_.position = 0;
|
||||
_loc5_.objectEncoding = 0;
|
||||
try
|
||||
{
|
||||
_loc6_ = _loc5_.readObject() as String;
|
||||
_loc7_ = _loc5_.readObject();
|
||||
_loc4_.metadata = _loc7_;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
if(param1.xmpMetadata.length() > 0)
|
||||
{
|
||||
_loc3_ = new Base64Decoder();
|
||||
_loc3_.decode(param1.xmpMetadata.text());
|
||||
_loc4_.xmp = _loc3_.drain();
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.F4M_PARSE_MEDIA_URL_MISSING));
|
||||
}
|
||||
|
||||
private function parseDVRInfo(param1:XML, param2:String, param3:Manifest) : void
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:String = null;
|
||||
var _loc4_:DVRInfo = new DVRInfo();
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc4_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc5_ = param1.@url;
|
||||
if(!this.isAbsoluteURL(_loc5_))
|
||||
{
|
||||
_loc5_ = param2 + "/" + _loc5_;
|
||||
}
|
||||
_loc4_.url = _loc5_;
|
||||
}
|
||||
if(param1.attribute("beginOffset").length() > 0)
|
||||
{
|
||||
_loc4_.beginOffset = Math.max(0,parseInt(param1.@beginOffset));
|
||||
}
|
||||
if(param1.attribute("endOffset").length() > 0)
|
||||
{
|
||||
_loc6_ = new Number(param1.@endOffset);
|
||||
if(_loc6_ > 0 && _loc6_ < 1)
|
||||
{
|
||||
_loc4_.endOffset = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_.endOffset = Math.max(0,_loc6_);
|
||||
}
|
||||
}
|
||||
if(param1.attribute("offline").length() > 0)
|
||||
{
|
||||
_loc7_ = param1.@offline;
|
||||
_loc4_.offline = _loc7_.toLowerCase() == "true";
|
||||
}
|
||||
param3.dvrInfo = _loc4_;
|
||||
}
|
||||
|
||||
private function parseDRMAdditionalHeader(param1:XML, param2:Vector.<Media>, param3:String, param4:Manifest) : void
|
||||
{
|
||||
var _loc6_:Media = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc9_:Base64Decoder = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc7_:DRMAdditionalHeader = new DRMAdditionalHeader();
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc7_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc5_ = param1.@url;
|
||||
if(!this.isAbsoluteURL(_loc5_))
|
||||
{
|
||||
_loc5_ = param3 + "/" + _loc5_;
|
||||
}
|
||||
_loc7_.url = _loc5_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = param1.text();
|
||||
_loc9_ = new Base64Decoder();
|
||||
_loc9_.decode(_loc8_);
|
||||
_loc7_.data = _loc9_.drain();
|
||||
}
|
||||
param4.drmAdditionalHeaders.push(_loc7_);
|
||||
for each(_loc6_ in param2)
|
||||
{
|
||||
if(_loc6_.drmAdditionalHeader.id == _loc7_.id)
|
||||
{
|
||||
_loc6_.drmAdditionalHeader = _loc7_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function parseBootstrapInfo(param1:XML, param2:Vector.<Media>, param3:String, param4:Manifest) : void
|
||||
{
|
||||
var _loc5_:Media = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc9_:Base64Decoder = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:BootstrapInfo = new BootstrapInfo();
|
||||
if(param1.attribute("profile").length() > 0)
|
||||
{
|
||||
_loc7_.profile = param1.@profile;
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc7_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc6_ = param1.@url;
|
||||
if(!this.isAbsoluteURL(_loc6_) && param3 != null)
|
||||
{
|
||||
_loc6_ = param3 + "/" + _loc6_;
|
||||
}
|
||||
_loc7_.url = _loc6_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = param1.text();
|
||||
_loc9_ = new Base64Decoder();
|
||||
_loc9_.decode(_loc8_);
|
||||
_loc7_.data = _loc9_.drain();
|
||||
}
|
||||
for each(_loc5_ in param2)
|
||||
{
|
||||
if(_loc5_.bootstrapInfo == null)
|
||||
{
|
||||
_loc5_.bootstrapInfo = _loc7_;
|
||||
}
|
||||
else if(_loc5_.bootstrapInfo.id == _loc7_.id)
|
||||
{
|
||||
_loc5_.bootstrapInfo = _loc7_;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.F4M_PARSE_PROFILE_MISSING));
|
||||
}
|
||||
|
||||
private function generateRTMPBaseURL(param1:Manifest) : void
|
||||
{
|
||||
var _loc2_:Media = null;
|
||||
if(param1.baseURL == null)
|
||||
{
|
||||
for each(_loc2_ in param1.media)
|
||||
{
|
||||
if(NetStreamUtils.isRTMPStream(_loc2_.url))
|
||||
{
|
||||
param1.baseURL = _loc2_.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createResource(param1:Manifest, param2:URLResource) : MediaResourceBase
|
||||
{
|
||||
var _loc5_:StreamingURLResource = null;
|
||||
var _loc6_:Media = null;
|
||||
var _loc7_:Vector.<String> = null;
|
||||
var _loc8_:String = null;
|
||||
var _loc9_:String = null;
|
||||
var _loc14_:String = null;
|
||||
var _loc15_:String = null;
|
||||
var _loc16_:DynamicStreamingResource = null;
|
||||
var _loc17_:Vector.<DynamicStreamingItem> = null;
|
||||
var _loc18_:String = null;
|
||||
var _loc19_:DynamicStreamingItem = null;
|
||||
var _loc3_:Metadata = null;
|
||||
var _loc4_:Metadata = null;
|
||||
var _loc10_:URL = new URL(param2.url);
|
||||
var _loc11_:String = "/" + _loc10_.path;
|
||||
_loc11_ = _loc11_.substr(0,_loc11_.lastIndexOf("/"));
|
||||
var _loc12_:String = _loc10_.protocol + "://" + _loc10_.host + (_loc10_.port != "" ? ":" + _loc10_.port : "") + _loc11_;
|
||||
if(param1.media.length == 1)
|
||||
{
|
||||
_loc6_ = param1.media[0] as Media;
|
||||
_loc8_ = _loc6_.url;
|
||||
_loc14_ = null;
|
||||
if(this.isAbsoluteURL(_loc8_))
|
||||
{
|
||||
_loc14_ = _loc6_.url.substr(0,_loc6_.url.lastIndexOf("/"));
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc14_ = param1.baseURL;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc14_ = _loc12_;
|
||||
}
|
||||
if(_loc6_.multicastGroupspec != null && _loc6_.multicastGroupspec.length > 0 && _loc6_.multicastStreamName != null && _loc6_.multicastStreamName.length > 0)
|
||||
{
|
||||
if(this.isAbsoluteURL(_loc8_))
|
||||
{
|
||||
_loc5_ = new MulticastResource(_loc8_,param1.streamType);
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc5_ = new MulticastResource(param1.baseURL + "/" + _loc8_,this.streamType(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = new MulticastResource(_loc12_ + "/" + _loc8_,this.streamType(param1));
|
||||
}
|
||||
MulticastResource(_loc5_).groupspec = _loc6_.multicastGroupspec;
|
||||
MulticastResource(_loc5_).streamName = _loc6_.multicastStreamName;
|
||||
}
|
||||
else if(this.isAbsoluteURL(_loc8_))
|
||||
{
|
||||
_loc5_ = new StreamingURLResource(_loc8_,param1.streamType);
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc5_ = new StreamingURLResource(param1.baseURL + "/" + _loc8_,this.streamType(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = new StreamingURLResource(_loc12_ + "/" + _loc8_,this.streamType(param1));
|
||||
}
|
||||
_loc5_.urlIncludesFMSApplicationInstance = param1.urlIncludesFMSApplicationInstance;
|
||||
if(_loc6_.bootstrapInfo != null)
|
||||
{
|
||||
_loc7_ = new Vector.<String>();
|
||||
_loc7_.push(_loc14_);
|
||||
_loc9_ = _loc6_.bootstrapInfo.url;
|
||||
if(_loc6_.bootstrapInfo.url != null && this.isAbsoluteURL(_loc6_.bootstrapInfo.url) == false)
|
||||
{
|
||||
_loc9_ = _loc12_ + "/" + _loc9_;
|
||||
_loc6_.bootstrapInfo.url = _loc9_;
|
||||
}
|
||||
_loc4_ = new Metadata();
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_BOOTSTRAP_KEY,_loc6_.bootstrapInfo);
|
||||
if(_loc7_.length > 0)
|
||||
{
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_SERVER_BASE_URLS_KEY,_loc7_);
|
||||
}
|
||||
}
|
||||
if(_loc6_.metadata != null)
|
||||
{
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = new Metadata();
|
||||
}
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_STREAM_METADATA_KEY,_loc6_.metadata);
|
||||
}
|
||||
if(_loc6_.xmp != null)
|
||||
{
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = new Metadata();
|
||||
}
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_XMP_METADATA_KEY,_loc6_.xmp);
|
||||
}
|
||||
if(_loc6_.drmAdditionalHeader != null)
|
||||
{
|
||||
_loc3_ = new Metadata();
|
||||
if(Media(param1.media[0]).drmAdditionalHeader != null && Media(param1.media[0]).drmAdditionalHeader.data != null)
|
||||
{
|
||||
_loc3_.addValue(MetadataNamespaces.DRM_ADDITIONAL_HEADER_KEY,Media(param1.media[0]).drmAdditionalHeader.data);
|
||||
_loc5_.drmContentData = this.extractDRMMetadata(Media(param1.media[0]).drmAdditionalHeader.data);
|
||||
}
|
||||
}
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc5_.addMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA,_loc4_);
|
||||
}
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc5_.addMetadataValue(MetadataNamespaces.DRM_METADATA,_loc3_);
|
||||
}
|
||||
}
|
||||
else if(param1.media.length > 1)
|
||||
{
|
||||
_loc15_ = param1.baseURL != null ? param1.baseURL : _loc12_;
|
||||
_loc7_ = new Vector.<String>();
|
||||
_loc7_.push(_loc15_);
|
||||
_loc16_ = new DynamicStreamingResource(_loc15_,this.streamType(param1));
|
||||
_loc16_.urlIncludesFMSApplicationInstance = param1.urlIncludesFMSApplicationInstance;
|
||||
_loc17_ = new Vector.<DynamicStreamingItem>();
|
||||
if(NetStreamUtils.isRTMPStream(_loc15_) == false)
|
||||
{
|
||||
_loc4_ = new Metadata();
|
||||
_loc16_.addMetadataValue(MetadataNamespaces.HTTP_STREAMING_METADATA,_loc4_);
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_SERVER_BASE_URLS_KEY,_loc7_);
|
||||
}
|
||||
for each(_loc6_ in param1.media)
|
||||
{
|
||||
if(this.isAbsoluteURL(_loc6_.url))
|
||||
{
|
||||
_loc18_ = NetStreamUtils.getStreamNameFromURL(_loc6_.url);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc18_ = _loc6_.url;
|
||||
}
|
||||
_loc19_ = new DynamicStreamingItem(_loc18_,_loc6_.bitrate,_loc6_.width,_loc6_.height);
|
||||
_loc17_.push(_loc19_);
|
||||
if(_loc6_.drmAdditionalHeader != null)
|
||||
{
|
||||
if(_loc16_.getMetadataValue(MetadataNamespaces.DRM_METADATA) == null)
|
||||
{
|
||||
_loc3_ = new Metadata();
|
||||
_loc16_.addMetadataValue(MetadataNamespaces.DRM_METADATA,_loc3_);
|
||||
}
|
||||
if(_loc6_.drmAdditionalHeader != null && _loc6_.drmAdditionalHeader.data != null)
|
||||
{
|
||||
_loc3_.addValue(_loc19_.streamName,this.extractDRMMetadata(_loc6_.drmAdditionalHeader.data));
|
||||
_loc3_.addValue(MetadataNamespaces.DRM_ADDITIONAL_HEADER_KEY + _loc19_.streamName,_loc6_.drmAdditionalHeader.data);
|
||||
}
|
||||
}
|
||||
if(_loc6_.bootstrapInfo != null)
|
||||
{
|
||||
_loc9_ = _loc6_.bootstrapInfo.url ? _loc6_.bootstrapInfo.url : null;
|
||||
if(_loc6_.bootstrapInfo.url != null && this.isAbsoluteURL(_loc6_.bootstrapInfo.url) == false)
|
||||
{
|
||||
_loc9_ = _loc12_ + "/" + _loc9_;
|
||||
_loc6_.bootstrapInfo.url = _loc9_;
|
||||
}
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_BOOTSTRAP_KEY + _loc19_.streamName,_loc6_.bootstrapInfo);
|
||||
}
|
||||
if(_loc6_.metadata != null)
|
||||
{
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_STREAM_METADATA_KEY + _loc19_.streamName,_loc6_.metadata);
|
||||
}
|
||||
if(_loc6_.xmp != null)
|
||||
{
|
||||
_loc4_.addValue(MetadataNamespaces.HTTP_STREAMING_XMP_METADATA_KEY + _loc19_.streamName,_loc6_.xmp);
|
||||
}
|
||||
}
|
||||
_loc16_.streamItems = _loc17_;
|
||||
_loc5_ = _loc16_;
|
||||
}
|
||||
else if(param1.baseURL == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString(OSMFStrings.F4M_PARSE_MEDIA_URL_MISSING));
|
||||
}
|
||||
if(param1.mimeType != null)
|
||||
{
|
||||
_loc5_.mediaType = MediaType.VIDEO;
|
||||
_loc5_.mimeType = param1.mimeType;
|
||||
}
|
||||
var _loc13_:StreamingURLResource = param2 as StreamingURLResource;
|
||||
if(_loc13_ != null)
|
||||
{
|
||||
_loc5_.clipStartTime = _loc13_.clipStartTime;
|
||||
_loc5_.clipEndTime = _loc13_.clipEndTime;
|
||||
}
|
||||
_loc5_.addMetadataValue(MetadataNamespaces.DERIVED_RESOURCE_METADATA,param2);
|
||||
this.addDVRInfo(param1,_loc5_);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function isAbsoluteURL(param1:String) : Boolean
|
||||
{
|
||||
var _loc2_:URL = new URL(param1);
|
||||
return _loc2_.absolute;
|
||||
}
|
||||
|
||||
private function extractDRMMetadata(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var header:Object = null;
|
||||
var encryption:Object = null;
|
||||
var enc:Object = null;
|
||||
var params:Object = null;
|
||||
var keyInfo:Object = null;
|
||||
var fmrmsMetadata:Object = null;
|
||||
var drmMetadata:String = null;
|
||||
var decoder:Base64Decoder = null;
|
||||
var data:ByteArray = param1;
|
||||
var metadata:ByteArray = null;
|
||||
data.position = 0;
|
||||
data.objectEncoding = 0;
|
||||
try
|
||||
{
|
||||
header = data.readObject();
|
||||
encryption = data.readObject();
|
||||
enc = encryption["Encryption"];
|
||||
params = enc["Params"];
|
||||
keyInfo = params["KeyInfo"];
|
||||
fmrmsMetadata = keyInfo["FMRMS_METADATA"];
|
||||
drmMetadata = fmrmsMetadata["Metadata"] as String;
|
||||
decoder = new Base64Decoder();
|
||||
decoder.decode(drmMetadata);
|
||||
metadata = decoder.drain();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
metadata = null;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private function addDVRInfo(param1:Manifest, param2:StreamingURLResource) : void
|
||||
{
|
||||
if(param1.dvrInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:Metadata = new Metadata();
|
||||
_loc3_.addValue(MetadataNamespaces.HTTP_STREAMING_DVR_BEGIN_OFFSET_KEY,param1.dvrInfo.beginOffset);
|
||||
_loc3_.addValue(MetadataNamespaces.HTTP_STREAMING_DVR_END_OFFSET_KEY,param1.dvrInfo.endOffset);
|
||||
_loc3_.addValue(MetadataNamespaces.HTTP_STREAMING_DVR_OFFLINE_KEY,param1.dvrInfo.offline);
|
||||
_loc3_.addValue(MetadataNamespaces.HTTP_STREAMING_DVR_ID_KEY,param1.dvrInfo.id);
|
||||
param2.addMetadataValue(MetadataNamespaces.DVR_METADATA,_loc3_);
|
||||
}
|
||||
|
||||
private function streamType(param1:Manifest) : String
|
||||
{
|
||||
return param1.streamType == StreamType.LIVE && param1.dvrInfo != null ? StreamType.DVR : param1.streamType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
internal class Media
|
||||
{
|
||||
|
||||
public var drmAdditionalHeader:DRMAdditionalHeader = new DRMAdditionalHeader();
|
||||
|
||||
public var bootstrapInfo:BootstrapInfo;
|
||||
|
||||
public var metadata:Object;
|
||||
|
||||
public var xmp:ByteArray;
|
||||
|
||||
public var url:String;
|
||||
|
||||
public var bitrate:Number;
|
||||
|
||||
public var moov:ByteArray;
|
||||
|
||||
public var width:Number;
|
||||
|
||||
public var height:Number;
|
||||
|
||||
public var multicastGroupspec:String;
|
||||
|
||||
public var multicastStreamName:String;
|
||||
|
||||
public function Media()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.osmf.elements.loaderClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.events.ProgressEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoaderLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _loader:Loader;
|
||||
|
||||
public function LoaderLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get loader() : Loader
|
||||
{
|
||||
return this._loader;
|
||||
}
|
||||
|
||||
public function set loader(param1:Loader) : void
|
||||
{
|
||||
this._loader = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == LoadState.LOADING)
|
||||
{
|
||||
this.loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,this.onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == LoadState.READY)
|
||||
{
|
||||
setBytesTotal(this.loader.contentLoaderInfo.bytesTotal);
|
||||
setBytesLoaded(this.loader.contentLoaderInfo.bytesLoaded);
|
||||
this.loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,this.onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == LoadState.UNINITIALIZED)
|
||||
{
|
||||
setBytesLoaded(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function onContentLoadProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
setBytesTotal(param1.bytesTotal);
|
||||
setBytesLoaded(param1.bytesLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package org.osmf.elements.loaderClasses
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Loader;
|
||||
import flash.display.LoaderInfo;
|
||||
import flash.errors.IOError;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.ApplicationDomain;
|
||||
import flash.system.Capabilities;
|
||||
import flash.system.LoaderContext;
|
||||
import flash.system.SecurityDomain;
|
||||
import flash.utils.Timer;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
public class LoaderUtils
|
||||
{
|
||||
|
||||
private static const SWF_MIME_TYPE:String = "application/x-shockwave-flash";
|
||||
|
||||
public function LoaderUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function createDisplayObjectTrait(param1:Loader, param2:MediaElement) : DisplayObjectTrait
|
||||
{
|
||||
var _loc3_:DisplayObject = null;
|
||||
var _loc4_:Number = 0;
|
||||
var _loc5_:Number = 0;
|
||||
var _loc6_:LoaderInfo = param1.contentLoaderInfo;
|
||||
_loc3_ = param1;
|
||||
_loc3_.scrollRect = new Rectangle(0,0,_loc6_.width,_loc6_.height);
|
||||
_loc4_ = _loc6_.width;
|
||||
_loc5_ = _loc6_.height;
|
||||
return new DisplayObjectTrait(_loc3_,_loc4_,_loc5_);
|
||||
}
|
||||
|
||||
public static function loadLoadTrait(param1:LoadTrait, param2:Function, param3:Boolean, param4:Boolean, param5:Function = null) : void
|
||||
{
|
||||
var context:LoaderContext;
|
||||
var urlReq:URLRequest;
|
||||
var loader:Loader = null;
|
||||
var onLoadComplete:Function = null;
|
||||
var onIOError:Function = null;
|
||||
var onSecurityError:Function = null;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var updateLoadTraitFunction:Function = param2;
|
||||
var useCurrentSecurityDomain:Boolean = param3;
|
||||
var checkPolicyFile:Boolean = param4;
|
||||
var validateLoadedContentFunction:Function = param5;
|
||||
var toggleLoaderListeners:Function = function(param1:Loader, param2:Boolean):void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
|
||||
param1.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
|
||||
param1.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSecurityError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.contentLoaderInfo.removeEventListener(Event.COMPLETE,onLoadComplete);
|
||||
param1.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onIOError);
|
||||
param1.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onSecurityError);
|
||||
}
|
||||
};
|
||||
onLoadComplete = function(param1:Event):void
|
||||
{
|
||||
var validated:Boolean = false;
|
||||
var timer:Timer = null;
|
||||
var onTimer:Function = null;
|
||||
var event:Event = param1;
|
||||
toggleLoaderListeners(loader,false);
|
||||
if(loadTrait.loadState == LoadState.LOADING)
|
||||
{
|
||||
if(validateLoadedContentFunction != null)
|
||||
{
|
||||
validated = Boolean(validateLoadedContentFunction(loader.content));
|
||||
if(validated)
|
||||
{
|
||||
if(Capabilities.isDebugger)
|
||||
{
|
||||
onTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
timer.removeEventListener(TimerEvent.TIMER_COMPLETE,onTimer);
|
||||
timer = null;
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
};
|
||||
timer = new Timer(250,1);
|
||||
timer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimer);
|
||||
timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.IO_ERROR)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLoadTraitFunction(loadTrait,LoadState.READY);
|
||||
}
|
||||
}
|
||||
};
|
||||
onIOError = function(param1:IOErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.IO_ERROR,param1 ? param1.text : param2)));
|
||||
};
|
||||
onSecurityError = function(param1:SecurityErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,LoadState.LOAD_ERROR);
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.SECURITY_ERROR,param1 ? param1.text : param2)));
|
||||
};
|
||||
var loaderLoadTrait:LoaderLoadTrait = loadTrait as LoaderLoadTrait;
|
||||
loader = new Loader();
|
||||
loaderLoadTrait.loader = loader;
|
||||
updateLoadTraitFunction(loadTrait,LoadState.LOADING);
|
||||
context = new LoaderContext();
|
||||
urlReq = new URLRequest((loadTrait.resource as URLResource).url.toString());
|
||||
context.checkPolicyFile = checkPolicyFile;
|
||||
if(useCurrentSecurityDomain && urlReq.url.search(/^file:\//i) == -1)
|
||||
{
|
||||
context.securityDomain = SecurityDomain.currentDomain;
|
||||
}
|
||||
if(validateLoadedContentFunction != null)
|
||||
{
|
||||
context.applicationDomain = new ApplicationDomain();
|
||||
}
|
||||
toggleLoaderListeners(loader,true);
|
||||
try
|
||||
{
|
||||
loader.load(urlReq,context);
|
||||
}
|
||||
catch(ioError:IOError)
|
||||
{
|
||||
onIOError(null,ioError.message);
|
||||
}
|
||||
catch(securityError:SecurityError)
|
||||
{
|
||||
onSecurityError(null,securityError.message);
|
||||
}
|
||||
}
|
||||
|
||||
public static function unloadLoadTrait(param1:LoadTrait, param2:Function) : void
|
||||
{
|
||||
var _loc3_:LoaderLoadTrait = param1 as LoaderLoadTrait;
|
||||
param2(param1,LoadState.UNLOADING);
|
||||
_loc3_.loader.unloadAndStop();
|
||||
param2(param1,LoadState.UNINITIALIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package org.osmf.elements.proxyClasses
|
||||
{
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoadFromDocumentLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _mediaElement:MediaElement;
|
||||
|
||||
public function LoadFromDocumentLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
override protected function loadStateChangeEnd() : void
|
||||
{
|
||||
dispatchEvent(new LoadEvent(LoadEvent.LOAD_STATE_CHANGE,false,false,loadState));
|
||||
}
|
||||
|
||||
public function set mediaElement(param1:MediaElement) : void
|
||||
{
|
||||
this._mediaElement = param1;
|
||||
}
|
||||
|
||||
public function get mediaElement() : MediaElement
|
||||
{
|
||||
return this._mediaElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.osmf.elements.proxyClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.Metadata;
|
||||
|
||||
public class ProxyMetadata extends Metadata
|
||||
{
|
||||
|
||||
private var proxiedMetadata:Metadata;
|
||||
|
||||
public function ProxyMetadata()
|
||||
{
|
||||
super();
|
||||
this.proxiedMetadata = new Metadata();
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_ADD,this.redispatchEvent);
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_CHANGE,this.redispatchEvent);
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_REMOVE,this.redispatchEvent);
|
||||
}
|
||||
|
||||
public function set metadata(param1:Metadata) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
this.proxiedMetadata.removeEventListener(MetadataEvent.VALUE_ADD,this.redispatchEvent);
|
||||
this.proxiedMetadata.removeEventListener(MetadataEvent.VALUE_CHANGE,this.redispatchEvent);
|
||||
this.proxiedMetadata.removeEventListener(MetadataEvent.VALUE_REMOVE,this.redispatchEvent);
|
||||
for each(_loc2_ in this.proxiedMetadata.keys)
|
||||
{
|
||||
param1.addValue(_loc2_,this.proxiedMetadata.getValue(_loc2_));
|
||||
}
|
||||
this.proxiedMetadata = param1;
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_ADD,this.redispatchEvent);
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_CHANGE,this.redispatchEvent);
|
||||
this.proxiedMetadata.addEventListener(MetadataEvent.VALUE_REMOVE,this.redispatchEvent);
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
return this.proxiedMetadata.getValue(param1);
|
||||
}
|
||||
|
||||
override public function addValue(param1:String, param2:Object) : void
|
||||
{
|
||||
this.proxiedMetadata.addValue(param1,param2);
|
||||
}
|
||||
|
||||
override public function removeValue(param1:String) : *
|
||||
{
|
||||
return this.proxiedMetadata.removeValue(param1);
|
||||
}
|
||||
|
||||
override public function get keys() : Vector.<String>
|
||||
{
|
||||
return this.proxiedMetadata.keys;
|
||||
}
|
||||
|
||||
private function redispatchEvent(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user