mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -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,33 @@
|
||||
package org.osmf.captioning
|
||||
{
|
||||
import org.osmf.captioning.media.CaptioningProxyElement;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaFactoryItem;
|
||||
import org.osmf.media.PluginInfo;
|
||||
import org.osmf.net.NetLoader;
|
||||
|
||||
public class CaptioningPluginInfo extends PluginInfo
|
||||
{
|
||||
|
||||
public static const CAPTIONING_METADATA_NAMESPACE:String = "http://www.osmf.org/captioning/1.0";
|
||||
|
||||
public static const CAPTIONING_METADATA_KEY_URI:String = "uri";
|
||||
|
||||
public static const CAPTIONING_TEMPORAL_METADATA_NAMESPACE:String = "http://www.osmf.org/temporal/captioning";
|
||||
|
||||
public function CaptioningPluginInfo()
|
||||
{
|
||||
var _loc3_:Vector.<MediaFactoryItem> = new Vector.<MediaFactoryItem>();
|
||||
var _loc2_:NetLoader = new NetLoader();
|
||||
var _loc1_:MediaFactoryItem = new MediaFactoryItem("org.osmf.captioning.CaptioningPluginInfo",_loc2_.canHandleResource,createCaptioningProxyElement,"proxy");
|
||||
_loc3_.push(_loc1_);
|
||||
super(_loc3_);
|
||||
}
|
||||
|
||||
private function createCaptioningProxyElement() : MediaElement
|
||||
{
|
||||
return new CaptioningProxyElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.osmf.captioning.loader
|
||||
{
|
||||
import org.osmf.captioning.model.CaptioningDocument;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class CaptioningLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var _document:CaptioningDocument;
|
||||
|
||||
public function CaptioningLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get document() : CaptioningDocument
|
||||
{
|
||||
return _document;
|
||||
}
|
||||
|
||||
public function set document(param1:CaptioningDocument) : void
|
||||
{
|
||||
_document = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.osmf.captioning.loader
|
||||
{
|
||||
import org.osmf.captioning.model.CaptioningDocument;
|
||||
import org.osmf.captioning.parsers.DFXPParser;
|
||||
import org.osmf.captioning.parsers.ICaptioningParser;
|
||||
import org.osmf.events.LoaderEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.utils.HTTPLoadTrait;
|
||||
import org.osmf.utils.HTTPLoader;
|
||||
|
||||
public class CaptioningLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private var httpLoader:HTTPLoader;
|
||||
|
||||
public function CaptioningLoader(param1:HTTPLoader = null)
|
||||
{
|
||||
super();
|
||||
this.httpLoader = param1 != null ? param1 : new HTTPLoader();
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
return httpLoader.canHandleResource(param1);
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
var httpLoadTrait:HTTPLoadTrait;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var onHTTPLoaderStateChange:* = function(param1:LoaderEvent):void
|
||||
{
|
||||
var _loc2_:ICaptioningParser = null;
|
||||
var _loc3_:CaptioningDocument = null;
|
||||
if(param1.newState == "ready")
|
||||
{
|
||||
httpLoader.removeEventListener("loadStateChange",onHTTPLoaderStateChange);
|
||||
httpLoadTrait.removeEventListener("mediaError",onLoadError);
|
||||
_loc2_ = createCaptioningParser();
|
||||
try
|
||||
{
|
||||
_loc3_ = _loc2_.parse(httpLoadTrait.urlLoader.data.toString());
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
}
|
||||
CaptioningLoadTrait(loadTrait).document = _loc3_;
|
||||
updateLoadTrait(loadTrait,"ready");
|
||||
}
|
||||
else if(param1.newState == "loadError")
|
||||
{
|
||||
httpLoader.removeEventListener("loadStateChange",onHTTPLoaderStateChange);
|
||||
updateLoadTrait(loadTrait,param1.newState);
|
||||
}
|
||||
};
|
||||
var onLoadError:* = function(param1:MediaErrorEvent):void
|
||||
{
|
||||
httpLoadTrait.removeEventListener("mediaError",onLoadError);
|
||||
loadTrait.dispatchEvent(param1.clone());
|
||||
};
|
||||
updateLoadTrait(loadTrait,"loading");
|
||||
httpLoader.addEventListener("loadStateChange",onHTTPLoaderStateChange);
|
||||
httpLoadTrait = new HTTPLoadTrait(httpLoader,loadTrait.resource);
|
||||
httpLoadTrait.addEventListener("mediaError",onLoadError);
|
||||
httpLoader.load(httpLoadTrait);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,"unloading");
|
||||
updateLoadTrait(param1,"uninitialized");
|
||||
}
|
||||
|
||||
protected function createCaptioningParser() : ICaptioningParser
|
||||
{
|
||||
return new DFXPParser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package org.osmf.captioning.media
|
||||
{
|
||||
import org.osmf.captioning.loader.CaptioningLoadTrait;
|
||||
import org.osmf.captioning.loader.CaptioningLoader;
|
||||
import org.osmf.captioning.model.Caption;
|
||||
import org.osmf.captioning.model.CaptioningDocument;
|
||||
import org.osmf.elements.ProxyElement;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.TimelineMetadata;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
|
||||
public class CaptioningProxyElement extends ProxyElement
|
||||
{
|
||||
|
||||
public static const MEDIA_ERROR_INVALID_PROXIED_ELEMENT:int = 2201;
|
||||
|
||||
private static const ERROR_MISSING_CAPTION_METADATA:String = "Media Element is missing Captioning metadata";
|
||||
|
||||
private static const ERROR_MISSING_RESOURCE:String = "Media Element is missing a valid resource";
|
||||
|
||||
private var loadTrait:CaptioningLoadTrait;
|
||||
|
||||
private var _continueLoadOnFailure:Boolean;
|
||||
|
||||
public function CaptioningProxyElement(param1:MediaElement = null, param2:Boolean = true)
|
||||
{
|
||||
super(param1);
|
||||
_continueLoadOnFailure = param2;
|
||||
}
|
||||
|
||||
public function get continueLoadOnFailure() : Boolean
|
||||
{
|
||||
return _continueLoadOnFailure;
|
||||
}
|
||||
|
||||
override public function set proxiedElement(param1:MediaElement) : void
|
||||
{
|
||||
var _loc3_:MediaElement = null;
|
||||
var _loc4_:MediaResourceBase = null;
|
||||
var _loc2_:Metadata = null;
|
||||
var _loc5_:String = null;
|
||||
super.proxiedElement = param1;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc3_ = super.proxiedElement;
|
||||
_loc4_ = _loc3_ && _loc3_.resource != null ? _loc3_.resource : resource;
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2201)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _loc4_.getMetadataValue("http://www.osmf.org/captioning/1.0") as Metadata;
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
if(!_continueLoadOnFailure)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2201)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc2_.getValue("uri");
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
loadTrait = new CaptioningLoadTrait(new CaptioningLoader(),new URLResource(_loc5_));
|
||||
loadTrait.addEventListener("loadStateChange",onLoadStateChange,false,99);
|
||||
addTrait("load",loadTrait);
|
||||
}
|
||||
else if(!_continueLoadOnFailure)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2201)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onLoadStateChange(param1:LoadEvent) : void
|
||||
{
|
||||
var _loc3_:CaptioningDocument = null;
|
||||
var _loc2_:MediaElement = null;
|
||||
var _loc6_:TimelineMetadata = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Caption = null;
|
||||
if(param1.loadState == "ready")
|
||||
{
|
||||
_loc3_ = loadTrait.document;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc2_ = super.proxiedElement;
|
||||
_loc6_ = proxiedElement.getMetadata("http://www.osmf.org/temporal/captioning") as TimelineMetadata;
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
_loc6_ = new TimelineMetadata(proxiedElement);
|
||||
proxiedElement.addMetadata("http://www.osmf.org/temporal/captioning",_loc6_);
|
||||
}
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc3_.numCaptions)
|
||||
{
|
||||
_loc5_ = _loc3_.getCaptionAt(_loc4_);
|
||||
_loc6_.addMarker(_loc5_);
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
cleanUp();
|
||||
}
|
||||
else if(param1.loadState == "loadError")
|
||||
{
|
||||
if(!_continueLoadOnFailure)
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function cleanUp() : void
|
||||
{
|
||||
removeTrait("load");
|
||||
var _loc1_:LoadTrait = getTrait("load") as LoadTrait;
|
||||
if(_loc1_ != null && _loc1_.loadState == "uninitialized")
|
||||
{
|
||||
_loc1_.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.osmf.captioning.model
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import org.osmf.metadata.TimelineMarker;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class Caption extends TimelineMarker
|
||||
{
|
||||
|
||||
private var _id:uint;
|
||||
|
||||
private var _captionText:String;
|
||||
|
||||
private var _formats:Vector.<CaptionFormat>;
|
||||
|
||||
public function Caption(param1:uint, param2:Number, param3:Number, param4:String)
|
||||
{
|
||||
var _loc5_:Number = param3 > 0 ? param3 - param2 : NaN;
|
||||
super(param2,_loc5_);
|
||||
_id = param1;
|
||||
_captionText = param4;
|
||||
}
|
||||
|
||||
public function addCaptionFormat(param1:CaptionFormat) : void
|
||||
{
|
||||
if(_formats == null)
|
||||
{
|
||||
_formats = new Vector.<CaptionFormat>();
|
||||
}
|
||||
_formats.push(param1);
|
||||
}
|
||||
|
||||
public function get numCaptionFormats() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_formats != null)
|
||||
{
|
||||
_loc1_ = int(_formats.length);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function getCaptionFormatAt(param1:int) : CaptionFormat
|
||||
{
|
||||
if(_formats == null || param1 >= _formats.length || param1 < 0)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return _formats[param1];
|
||||
}
|
||||
|
||||
public function get text() : String
|
||||
{
|
||||
return _captionText;
|
||||
}
|
||||
|
||||
public function get clearText() : String
|
||||
{
|
||||
var _loc1_:String = "";
|
||||
if(_captionText != null && _captionText.length > 0)
|
||||
{
|
||||
_loc1_ = _captionText.replace(/<(.|\n)*?>/g,"");
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.osmf.captioning.model
|
||||
{
|
||||
public class CaptionFormat
|
||||
{
|
||||
|
||||
public static const UNDEFINED_INDEX:int = -1;
|
||||
|
||||
private static const MISSING_STYLE_ERROR_MSG:String = "CaptionStyle is required for CaptionFormat objects";
|
||||
|
||||
private var _startIndex:int;
|
||||
|
||||
private var _endIndex:int;
|
||||
|
||||
private var _style:CaptionStyle;
|
||||
|
||||
public function CaptionFormat(param1:CaptionStyle, param2:int = -1, param3:int = -1)
|
||||
{
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError("CaptionStyle is required for CaptionFormat objects");
|
||||
}
|
||||
_startIndex = param2;
|
||||
_endIndex = param3;
|
||||
_style = param1;
|
||||
}
|
||||
|
||||
public function get startIndex() : int
|
||||
{
|
||||
return _startIndex;
|
||||
}
|
||||
|
||||
public function get endIndex() : int
|
||||
{
|
||||
return _endIndex;
|
||||
}
|
||||
|
||||
public function get style() : CaptionStyle
|
||||
{
|
||||
return _style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package org.osmf.captioning.model
|
||||
{
|
||||
public class CaptionStyle
|
||||
{
|
||||
|
||||
private var _id:String;
|
||||
|
||||
private var _backgroundColor:Object;
|
||||
|
||||
private var _backgroundColorAlpha:Object;
|
||||
|
||||
private var _textColor:Object;
|
||||
|
||||
private var _textColorAlpha:Object;
|
||||
|
||||
private var _fontFamily:String;
|
||||
|
||||
private var _fontSize:int;
|
||||
|
||||
private var _fontStyle:String;
|
||||
|
||||
private var _fontWeight:String;
|
||||
|
||||
private var _textAlign:String;
|
||||
|
||||
private var _wrapOption:Boolean;
|
||||
|
||||
public function CaptionStyle(param1:String)
|
||||
{
|
||||
super();
|
||||
_id = param1;
|
||||
}
|
||||
|
||||
public function get id() : String
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public function get backgroundColor() : Object
|
||||
{
|
||||
return _backgroundColor;
|
||||
}
|
||||
|
||||
public function set backgroundColor(param1:Object) : void
|
||||
{
|
||||
_backgroundColor = param1;
|
||||
}
|
||||
|
||||
public function get backgroundColorAlpha() : Object
|
||||
{
|
||||
return _backgroundColorAlpha;
|
||||
}
|
||||
|
||||
public function set backgroundColorAlpha(param1:Object) : void
|
||||
{
|
||||
_backgroundColorAlpha = param1;
|
||||
}
|
||||
|
||||
public function get textColor() : Object
|
||||
{
|
||||
return _textColor;
|
||||
}
|
||||
|
||||
public function set textColor(param1:Object) : void
|
||||
{
|
||||
_textColor = param1;
|
||||
}
|
||||
|
||||
public function get textColorAlpha() : Object
|
||||
{
|
||||
return _textColorAlpha;
|
||||
}
|
||||
|
||||
public function set textColorAlpha(param1:Object) : void
|
||||
{
|
||||
_textColorAlpha = param1;
|
||||
}
|
||||
|
||||
public function get fontFamily() : String
|
||||
{
|
||||
return _fontFamily;
|
||||
}
|
||||
|
||||
public function set fontFamily(param1:String) : void
|
||||
{
|
||||
_fontFamily = param1;
|
||||
}
|
||||
|
||||
public function get fontSize() : int
|
||||
{
|
||||
return _fontSize;
|
||||
}
|
||||
|
||||
public function set fontSize(param1:int) : void
|
||||
{
|
||||
_fontSize = param1;
|
||||
}
|
||||
|
||||
public function get fontStyle() : String
|
||||
{
|
||||
return _fontStyle;
|
||||
}
|
||||
|
||||
public function set fontStyle(param1:String) : void
|
||||
{
|
||||
_fontStyle = param1;
|
||||
}
|
||||
|
||||
public function get fontWeight() : String
|
||||
{
|
||||
return _fontWeight;
|
||||
}
|
||||
|
||||
public function set fontWeight(param1:String) : void
|
||||
{
|
||||
_fontWeight = param1;
|
||||
}
|
||||
|
||||
public function get textAlign() : String
|
||||
{
|
||||
return _textAlign;
|
||||
}
|
||||
|
||||
public function set textAlign(param1:String) : void
|
||||
{
|
||||
_textAlign = param1;
|
||||
}
|
||||
|
||||
public function get wrapOption() : Boolean
|
||||
{
|
||||
return _wrapOption;
|
||||
}
|
||||
|
||||
public function set wrapOption(param1:Boolean) : void
|
||||
{
|
||||
_wrapOption = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package org.osmf.captioning.model
|
||||
{
|
||||
import flash.errors.IllegalOperationError;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class CaptioningDocument
|
||||
{
|
||||
|
||||
private var _title:String;
|
||||
|
||||
private var _desc:String;
|
||||
|
||||
private var _copyright:String;
|
||||
|
||||
private var _captions:Vector.<Caption>;
|
||||
|
||||
private var _styles:Vector.<CaptionStyle>;
|
||||
|
||||
public function CaptioningDocument()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get title() : String
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
public function set title(param1:String) : void
|
||||
{
|
||||
_title = param1;
|
||||
}
|
||||
|
||||
public function get description() : String
|
||||
{
|
||||
return _desc;
|
||||
}
|
||||
|
||||
public function set description(param1:String) : void
|
||||
{
|
||||
_desc = param1;
|
||||
}
|
||||
|
||||
public function get copyright() : String
|
||||
{
|
||||
return _copyright;
|
||||
}
|
||||
|
||||
public function set copyright(param1:String) : void
|
||||
{
|
||||
_copyright = param1;
|
||||
}
|
||||
|
||||
public function addStyle(param1:CaptionStyle) : void
|
||||
{
|
||||
if(_styles == null)
|
||||
{
|
||||
_styles = new Vector.<CaptionStyle>();
|
||||
}
|
||||
_styles.push(param1);
|
||||
}
|
||||
|
||||
public function get numStyles() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_styles != null)
|
||||
{
|
||||
_loc1_ = int(_styles.length);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function getStyleAt(param1:int) : CaptionStyle
|
||||
{
|
||||
if(_styles == null || param1 >= _styles.length)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return _styles[param1];
|
||||
}
|
||||
|
||||
public function addCaption(param1:Caption) : void
|
||||
{
|
||||
if(_captions == null)
|
||||
{
|
||||
_captions = new Vector.<Caption>();
|
||||
}
|
||||
_captions.push(param1);
|
||||
}
|
||||
|
||||
public function get numCaptions() : int
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_captions != null)
|
||||
{
|
||||
_loc1_ = int(_captions.length);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function getCaptionAt(param1:int) : Caption
|
||||
{
|
||||
if(_captions == null || param1 >= _captions.length)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return _captions[param1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,507 @@
|
||||
package org.osmf.captioning.parsers
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.captioning.model.Caption;
|
||||
import org.osmf.captioning.model.CaptionFormat;
|
||||
import org.osmf.captioning.model.CaptionStyle;
|
||||
import org.osmf.captioning.model.CaptioningDocument;
|
||||
import org.osmf.utils.TimeUtil;
|
||||
|
||||
public class DFXPParser implements ICaptioningParser
|
||||
{
|
||||
|
||||
private var ns:Namespace;
|
||||
|
||||
private var ttm:Namespace;
|
||||
|
||||
private var tts:Namespace;
|
||||
|
||||
private var rootNamespace:Namespace;
|
||||
|
||||
private var namedColorMap:Dictionary;
|
||||
|
||||
public function DFXPParser()
|
||||
{
|
||||
super();
|
||||
namedColorMap = new Dictionary();
|
||||
namedColorMap["transparent"] = 0;
|
||||
namedColorMap["black"] = 0;
|
||||
namedColorMap["silver"] = 12632256;
|
||||
namedColorMap["gray"] = 8421504;
|
||||
namedColorMap["white"] = 16777215;
|
||||
namedColorMap["maroon"] = 8388608;
|
||||
namedColorMap["red"] = 16711680;
|
||||
namedColorMap["purple"] = 8388736;
|
||||
namedColorMap["fuchsia"] = 16711935;
|
||||
namedColorMap["magenta"] = 16711935;
|
||||
namedColorMap["green"] = 32768;
|
||||
namedColorMap["lime"] = 65280;
|
||||
namedColorMap["olive"] = 8421376;
|
||||
namedColorMap["yellow"] = 16776960;
|
||||
namedColorMap["navy"] = 128;
|
||||
namedColorMap["blue"] = 255;
|
||||
namedColorMap["teal"] = 32896;
|
||||
namedColorMap["aqua"] = 65535;
|
||||
namedColorMap["cyan"] = 65535;
|
||||
}
|
||||
|
||||
public function parse(param1:String) : CaptioningDocument
|
||||
{
|
||||
var _loc2_:XML = null;
|
||||
var _loc3_:CaptioningDocument = new CaptioningDocument();
|
||||
var _loc4_:Boolean = Boolean(XML.ignoreWhitespace);
|
||||
var _loc6_:Boolean = Boolean(XML.prettyPrinting);
|
||||
var _loc5_:String = param1.replace(/\s+$/,"");
|
||||
_loc5_ = _loc5_.replace(/>\s+</g,"><");
|
||||
XML.ignoreWhitespace = false;
|
||||
XML.prettyPrinting = false;
|
||||
try
|
||||
{
|
||||
_loc2_ = new XML(_loc5_);
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
debugLog("Unhandled exception in DFXPParser : " + e.message);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
XML.ignoreWhitespace = _loc4_;
|
||||
XML.prettyPrinting = _loc6_;
|
||||
}
|
||||
rootNamespace = _loc2_.namespace();
|
||||
ns = _loc2_.namespace();
|
||||
ttm = _loc2_.namespace("ttm");
|
||||
tts = _loc2_.namespace("tts");
|
||||
try
|
||||
{
|
||||
parseHead(_loc3_,_loc2_);
|
||||
parseBody(_loc3_,_loc2_);
|
||||
}
|
||||
catch(err:Error)
|
||||
{
|
||||
debugLog("Unhandled exception in DFXPParser : " + err.message);
|
||||
throw err;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function parseHead(param1:CaptioningDocument, param2:XML) : void
|
||||
{
|
||||
var _loc7_:XMLList = null;
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:XML = null;
|
||||
var _loc3_:CaptionStyle = null;
|
||||
try
|
||||
{
|
||||
param1.title = param2..ttm::title.text();
|
||||
param1.description = param2..ttm::desc.text();
|
||||
param1.copyright = param2..ttm::copyright.text();
|
||||
}
|
||||
catch(err:Error)
|
||||
{
|
||||
if(err.errorID != 1080)
|
||||
{
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
var _loc4_:XMLList = param2..ns::styling;
|
||||
if(_loc4_.length())
|
||||
{
|
||||
_loc7_ = _loc4_.children();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc7_.length())
|
||||
{
|
||||
_loc5_ = _loc7_[_loc6_];
|
||||
_loc3_ = createStyleObject(_loc5_);
|
||||
param1.addStyle(_loc3_);
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createStyleObject(param1:XML) : CaptionStyle
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc6_:String = param1.@id;
|
||||
var _loc2_:CaptionStyle = new CaptionStyle(_loc6_);
|
||||
var _loc3_:String = param1.tts::@backgroundColor;
|
||||
if(_loc3_ != "")
|
||||
{
|
||||
_loc4_ = parseColor(_loc3_);
|
||||
_loc2_.backgroundColor = _loc4_.color;
|
||||
_loc2_.backgroundColorAlpha = _loc4_.alpha;
|
||||
}
|
||||
_loc2_.textAlign = param1.tts::@textAlign;
|
||||
_loc3_ = param1.tts::@color;
|
||||
if(_loc3_ != "")
|
||||
{
|
||||
_loc4_ = parseColor(_loc3_);
|
||||
_loc2_.textColor = _loc4_.color;
|
||||
_loc2_.textColorAlpha = _loc4_.alpha;
|
||||
}
|
||||
_loc2_.fontFamily = parseFontFamily(param1.tts::@fontFamily);
|
||||
var _loc5_:String = parseFontSize(param1.tts::@fontSize);
|
||||
_loc2_.fontSize = parseInt(_loc5_);
|
||||
_loc2_.fontStyle = param1.tts::@fontStyle;
|
||||
_loc2_.fontWeight = param1.tts::@fontWeight;
|
||||
_loc2_.wrapOption = String(param1.tts::@wrapOption).toLowerCase() == "nowrap" ? false : true;
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function parseColor(param1:String) : Object
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc3_:RegExp = /^\s*#([\dA-Fa-f][\dA-Fa-f][\dA-Fa-f][\dA-Fa-f][\dA-Fa-f][\dA-Fa-f])([\dA-Fa-f][\dA-Fa-f])?\s*$/;
|
||||
var _loc2_:Array = param1.match(_loc3_);
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc4_ = parseInt(_loc2_[1],16);
|
||||
if(_loc2_.length == 3)
|
||||
{
|
||||
_loc5_ = parseInt(_loc2_[2]) / 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = /^\s*rgb(a)?\((\d+),(\d+),(\d+)(\)|(,(\d+)\)))\s*$/i;
|
||||
_loc2_ = param1.match(_loc3_);
|
||||
if(_loc2_ != null && _loc2_.length >= 5)
|
||||
{
|
||||
_loc4_ = (parseInt(_loc2_[2]) << 16) + (parseInt(_loc2_[3]) << 8) + parseInt(_loc2_[4]);
|
||||
if(_loc2_.length == 8 && _loc2_[7] != undefined)
|
||||
{
|
||||
_loc5_ = parseInt(_loc2_[7]) / 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = namedColorMap[param1.toLowerCase()];
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = parseInt(param1);
|
||||
if(isNaN(int(_loc4_)))
|
||||
{
|
||||
_loc4_ = null;
|
||||
debugLog("Invalid DFXP document: invalid color value of " + param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
"color":_loc4_,
|
||||
"alpha":_loc5_
|
||||
};
|
||||
}
|
||||
|
||||
private function parseFontSize(param1:String) : String
|
||||
{
|
||||
var _loc8_:RegExp = null;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:RegExp = null;
|
||||
var _loc2_:Object = null;
|
||||
if(!param1 || param1 == "")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var _loc3_:String = "";
|
||||
var _loc6_:RegExp = new RegExp(/^\s*\d+%.*$/);
|
||||
var _loc5_:Object = _loc6_.exec(param1);
|
||||
if(_loc5_)
|
||||
{
|
||||
debugLog("Invalid DFXP document: percentages are not supported for font size.");
|
||||
_loc3_ = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = new RegExp(/^\s*[\+\-]\d.*/);
|
||||
_loc4_ = _loc8_.exec(param1);
|
||||
if(_loc4_)
|
||||
{
|
||||
debugLog("Invalid DFXP document: increment values are not supported for font size.");
|
||||
_loc3_ = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = new RegExp(/^\s*(\d+).*$/);
|
||||
_loc2_ = _loc7_.exec(param1);
|
||||
if(_loc2_ && _loc2_[1] != undefined)
|
||||
{
|
||||
_loc3_ = _loc2_[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function parseFontFamily(param1:String) : String
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(!param1 || param1 == "")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var _loc3_:String = "";
|
||||
var _loc5_:RegExp = new RegExp(/^\s*([^,\s]+)\s*((,\s*([^,\s]+)\s*)*)$/);
|
||||
var _loc4_:Boolean = false;
|
||||
do
|
||||
{
|
||||
_loc2_ = _loc5_.exec(param1);
|
||||
if(!_loc2_)
|
||||
{
|
||||
_loc4_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc3_.length > 0)
|
||||
{
|
||||
_loc3_ += ",";
|
||||
}
|
||||
switch(_loc2_[1])
|
||||
{
|
||||
case "default":
|
||||
case "serif":
|
||||
case "proportionalSerif":
|
||||
_loc3_ += "_serif";
|
||||
break;
|
||||
case "monospace":
|
||||
case "monospaceSansSerif":
|
||||
case "monospaceSerif":
|
||||
_loc3_ += "_typewriter";
|
||||
break;
|
||||
case "sansSerif":
|
||||
case "proportionalSansSerif":
|
||||
_loc3_ += "_sans";
|
||||
break;
|
||||
default:
|
||||
_loc3_ += _loc2_[1];
|
||||
}
|
||||
if(_loc2_[2] != undefined && _loc2_[2] != "")
|
||||
{
|
||||
param1 = _loc2_[2].slice(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!_loc4_);
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function parseBody(param1:CaptioningDocument, param2:XML) : void
|
||||
{
|
||||
var _loc3_:XMLList = null;
|
||||
var _loc4_:XMLList = null;
|
||||
var _loc5_:* = 0;
|
||||
var _loc7_:XML = null;
|
||||
var _loc6_:XMLList = param2..ns::body;
|
||||
if(_loc6_.length() <= 0)
|
||||
{
|
||||
debugLog("Invalid DFXP document: <body> tag is required.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = param2..ns::div;
|
||||
_loc4_ = _loc3_.length() ? _loc3_.children() : (_loc6_.length() ? _loc6_.children() : new XMLList());
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_.length())
|
||||
{
|
||||
_loc7_ = _loc4_[_loc5_];
|
||||
if(rootNamespace == _loc7_.namespace())
|
||||
{
|
||||
parsePTag(param1,_loc7_,_loc5_);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugLog("Ignoring this tag, foreign namespaces not supported: \"" + _loc7_ + "\"");
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function parsePTag(param1:CaptioningDocument, param2:XML, param3:uint) : void
|
||||
{
|
||||
var _loc10_:* = 0;
|
||||
var _loc22_:XML = null;
|
||||
var _loc20_:* = 0;
|
||||
var _loc11_:* = null;
|
||||
var _loc5_:Array = null;
|
||||
var _loc6_:* = 0;
|
||||
var _loc12_:CaptionFormat = null;
|
||||
var _loc17_:CaptionFormat = null;
|
||||
var _loc19_:String = param2.@begin;
|
||||
var _loc16_:String = param2.@end;
|
||||
var _loc4_:String = param2.@dur;
|
||||
if(_loc19_ == "")
|
||||
{
|
||||
_loc19_ = "0s";
|
||||
}
|
||||
var _loc9_:Number = TimeUtil.parseTime(_loc19_);
|
||||
var _loc13_:Number = 0;
|
||||
if(_loc16_ != "")
|
||||
{
|
||||
_loc13_ = TimeUtil.parseTime(_loc16_);
|
||||
}
|
||||
else if(_loc4_ != "")
|
||||
{
|
||||
_loc13_ = _loc9_ + TimeUtil.parseTime(_loc4_);
|
||||
}
|
||||
var _loc7_:Array = [];
|
||||
var _loc18_:String = new String("<p>");
|
||||
var _loc15_:XMLList = param2.children();
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < _loc15_.length())
|
||||
{
|
||||
switch((_loc22_ = _loc15_[_loc10_]).nodeKind())
|
||||
{
|
||||
case "text":
|
||||
_loc18_ += formatCCText(_loc22_.toString());
|
||||
break;
|
||||
case "element":
|
||||
switch(_loc22_.localName())
|
||||
{
|
||||
case "set":
|
||||
case "metadata":
|
||||
break;
|
||||
case "span":
|
||||
_loc20_ = uint(calcClearTextLength(_loc18_));
|
||||
_loc5_ = [];
|
||||
_loc18_ += parseSpanTag(param1,_loc22_,_loc5_);
|
||||
_loc6_ = uint(calcClearTextLength(_loc18_));
|
||||
for each(var _loc8_:CaptionStyle in _loc5_)
|
||||
{
|
||||
_loc12_ = new CaptionFormat(_loc8_,_loc20_,_loc6_);
|
||||
_loc7_.push(_loc12_);
|
||||
}
|
||||
break;
|
||||
case "br":
|
||||
_loc18_ += "<br />";
|
||||
break;
|
||||
default:
|
||||
_loc18_ += formatCCText(_loc22_.toString());
|
||||
}
|
||||
}
|
||||
_loc10_++;
|
||||
}
|
||||
_loc18_ += "</p>";
|
||||
var _loc21_:Caption = new Caption(param3,_loc9_,_loc13_,_loc18_);
|
||||
var _loc14_:CaptionStyle = parseStyleAttrib(param1,param2);
|
||||
if(_loc14_)
|
||||
{
|
||||
_loc17_ = new CaptionFormat(_loc14_);
|
||||
_loc21_.addCaptionFormat(_loc17_);
|
||||
}
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < _loc7_.length)
|
||||
{
|
||||
_loc21_.addCaptionFormat(_loc7_[_loc10_]);
|
||||
_loc10_++;
|
||||
}
|
||||
param1.addCaption(_loc21_);
|
||||
}
|
||||
|
||||
private function parseStyleAttrib(param1:CaptioningDocument, param2:XML) : CaptionStyle
|
||||
{
|
||||
var _loc7_:* = 0;
|
||||
var _loc8_:XMLList = null;
|
||||
var _loc5_:XML = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc6_:String = param2.@style;
|
||||
var _loc3_:CaptionStyle = null;
|
||||
if(_loc6_ != "")
|
||||
{
|
||||
while(_loc7_ < param1.numStyles)
|
||||
{
|
||||
if(param1.getStyleAt(_loc7_).id == _loc6_)
|
||||
{
|
||||
_loc3_ = param1.getStyleAt(_loc7_);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
_loc8_ = param2.tts::@*;
|
||||
}
|
||||
catch(err:Error)
|
||||
{
|
||||
if(err.errorID != 1080)
|
||||
{
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
_loc7_ = 0;
|
||||
while(_loc8_ != null && _loc7_ < _loc8_.length())
|
||||
{
|
||||
_loc5_ = _loc8_[_loc7_];
|
||||
_loc4_ = _loc5_.localName();
|
||||
if(_loc4_ != "inherit")
|
||||
{
|
||||
_loc3_ = createStyleObject(param2);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function parseSpanTag(param1:CaptioningDocument, param2:XML, param3:Array) : String
|
||||
{
|
||||
var _loc7_:* = 0;
|
||||
var _loc8_:XML = null;
|
||||
var _loc4_:CaptionStyle = parseStyleAttrib(param1,param2);
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
param3.push(_loc4_);
|
||||
}
|
||||
var _loc6_:String = new String();
|
||||
var _loc5_:XMLList = param2.children();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.length())
|
||||
{
|
||||
switch((_loc8_ = _loc5_[_loc7_]).nodeKind())
|
||||
{
|
||||
case "text":
|
||||
_loc6_ += formatCCText(_loc8_.toString());
|
||||
break;
|
||||
case "element":
|
||||
switch(_loc8_.localName())
|
||||
{
|
||||
case "set":
|
||||
case "metadata":
|
||||
break;
|
||||
case "br":
|
||||
_loc6_ += "<br/>";
|
||||
break;
|
||||
default:
|
||||
_loc6_ += _loc8_.toString();
|
||||
}
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function formatCCText(param1:String) : String
|
||||
{
|
||||
return param1.replace(/\s+/g," ");
|
||||
}
|
||||
|
||||
private function calcClearTextLength(param1:String) : int
|
||||
{
|
||||
var _loc2_:String = param1.replace(/<(.|\n)*?>/g,"");
|
||||
return _loc2_.length;
|
||||
}
|
||||
|
||||
private function debugLog(param1:String) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.osmf.captioning.parsers
|
||||
{
|
||||
import org.osmf.captioning.model.CaptioningDocument;
|
||||
|
||||
public interface ICaptioningParser
|
||||
{
|
||||
|
||||
function parse(param1:String) : CaptioningDocument;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.osmf.containers
|
||||
{
|
||||
import org.osmf.media.MediaElement;
|
||||
|
||||
public interface IMediaContainer
|
||||
{
|
||||
|
||||
function addMediaElement(param1:MediaElement) : MediaElement;
|
||||
|
||||
function removeMediaElement(param1:MediaElement) : MediaElement;
|
||||
|
||||
function containsMediaElement(param1:MediaElement) : Boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
package org.osmf.containers
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.ContainerChangeEvent;
|
||||
import org.osmf.layout.LayoutMetadata;
|
||||
import org.osmf.layout.LayoutRenderer;
|
||||
import org.osmf.layout.LayoutRendererBase;
|
||||
import org.osmf.layout.LayoutTargetEvent;
|
||||
import org.osmf.layout.LayoutTargetSprite;
|
||||
import org.osmf.layout.MediaElementLayoutTarget;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaContainer extends LayoutTargetSprite implements IMediaContainer
|
||||
{
|
||||
|
||||
private var layoutTargets:Dictionary = new Dictionary();
|
||||
|
||||
private var _layoutRenderer:LayoutRendererBase;
|
||||
|
||||
private var _backgroundColor:Number;
|
||||
|
||||
private var _backgroundAlpha:Number;
|
||||
|
||||
private var lastAvailableWidth:Number;
|
||||
|
||||
private var lastAvailableHeight:Number;
|
||||
|
||||
public function MediaContainer(param1:LayoutRendererBase = null, param2:LayoutMetadata = null)
|
||||
{
|
||||
super(param2);
|
||||
_layoutRenderer = param1 || new LayoutRenderer();
|
||||
_layoutRenderer.container = this;
|
||||
}
|
||||
|
||||
public function addMediaElement(param1:MediaElement) : MediaElement
|
||||
{
|
||||
var _loc2_:MediaElementLayoutTarget = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(layoutTargets[param1] == undefined)
|
||||
{
|
||||
param1.dispatchEvent(new ContainerChangeEvent("containerChange",false,false,param1.container,this));
|
||||
_loc2_ = MediaElementLayoutTarget.getInstance(param1);
|
||||
layoutTargets[param1] = _loc2_;
|
||||
_layoutRenderer.addTarget(_loc2_);
|
||||
param1.addEventListener("containerChange",onElementContainerChange);
|
||||
return param1;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
|
||||
public function removeMediaElement(param1:MediaElement) : MediaElement
|
||||
{
|
||||
var _loc2_:MediaElement = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
var _loc3_:MediaElementLayoutTarget = layoutTargets[param1];
|
||||
if(_loc3_)
|
||||
{
|
||||
param1.removeEventListener("containerChange",onElementContainerChange);
|
||||
_layoutRenderer.removeTarget(_loc3_);
|
||||
delete layoutTargets[param1];
|
||||
_loc2_ = param1;
|
||||
if(param1.container == this)
|
||||
{
|
||||
param1.dispatchEvent(new ContainerChangeEvent("containerChange",false,false,param1.container,null));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
|
||||
public function containsMediaElement(param1:MediaElement) : Boolean
|
||||
{
|
||||
return layoutTargets[param1] != undefined;
|
||||
}
|
||||
|
||||
public function get layoutRenderer() : LayoutRendererBase
|
||||
{
|
||||
return _layoutRenderer;
|
||||
}
|
||||
|
||||
public function get clipChildren() : Boolean
|
||||
{
|
||||
return scrollRect != null;
|
||||
}
|
||||
|
||||
public function set clipChildren(param1:Boolean) : void
|
||||
{
|
||||
if(param1 && scrollRect == null)
|
||||
{
|
||||
scrollRect = new Rectangle(0,0,_layoutRenderer.measuredWidth,_layoutRenderer.measuredHeight);
|
||||
}
|
||||
else if(param1 == false && scrollRect)
|
||||
{
|
||||
scrollRect = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function get backgroundColor() : Number
|
||||
{
|
||||
return _backgroundColor;
|
||||
}
|
||||
|
||||
public function set backgroundColor(param1:Number) : void
|
||||
{
|
||||
if(param1 != _backgroundColor)
|
||||
{
|
||||
_backgroundColor = param1;
|
||||
drawBackground();
|
||||
}
|
||||
}
|
||||
|
||||
public function get backgroundAlpha() : Number
|
||||
{
|
||||
return _backgroundAlpha;
|
||||
}
|
||||
|
||||
public function set backgroundAlpha(param1:Number) : void
|
||||
{
|
||||
if(param1 != _backgroundAlpha)
|
||||
{
|
||||
_backgroundAlpha = param1;
|
||||
drawBackground();
|
||||
}
|
||||
}
|
||||
|
||||
override public function layout(param1:Number, param2:Number, param3:Boolean = true) : void
|
||||
{
|
||||
super.layout(param1,param2,param3);
|
||||
lastAvailableWidth = param1;
|
||||
lastAvailableHeight = param2;
|
||||
if(!isNaN(backgroundColor))
|
||||
{
|
||||
drawBackground();
|
||||
}
|
||||
if(scrollRect)
|
||||
{
|
||||
scrollRect = new Rectangle(0,0,param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
override public function validateNow() : void
|
||||
{
|
||||
_layoutRenderer.validateNow();
|
||||
}
|
||||
|
||||
override public function addChild(param1:DisplayObject) : DisplayObject
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("directDisplayListModError"));
|
||||
}
|
||||
|
||||
override public function addChildAt(param1:DisplayObject, param2:int) : DisplayObject
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("directDisplayListModError"));
|
||||
}
|
||||
|
||||
override public function removeChild(param1:DisplayObject) : DisplayObject
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("directDisplayListModError"));
|
||||
}
|
||||
|
||||
override public function setChildIndex(param1:DisplayObject, param2:int) : void
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("directDisplayListModError"));
|
||||
}
|
||||
|
||||
override protected function onAddChildAt(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
super.addChildAt(param1.displayObject,param1.index);
|
||||
}
|
||||
|
||||
override protected function onRemoveChild(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
super.removeChild(param1.displayObject);
|
||||
}
|
||||
|
||||
override protected function onSetChildIndex(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
super.setChildIndex(param1.displayObject,param1.index);
|
||||
}
|
||||
|
||||
private function drawBackground() : void
|
||||
{
|
||||
graphics.clear();
|
||||
if(!isNaN(_backgroundColor) && _backgroundAlpha != 0 && lastAvailableWidth && lastAvailableHeight)
|
||||
{
|
||||
graphics.beginFill(_backgroundColor,_backgroundAlpha);
|
||||
graphics.drawRect(0,0,lastAvailableWidth,lastAvailableHeight);
|
||||
graphics.endFill();
|
||||
}
|
||||
}
|
||||
|
||||
private function onElementContainerChange(param1:ContainerChangeEvent) : void
|
||||
{
|
||||
if(param1.oldContainer == this)
|
||||
{
|
||||
removeMediaElement(param1.target as MediaElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
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.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.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("invalidParam"));
|
||||
}
|
||||
}
|
||||
|
||||
public function get defaultDuration() : Number
|
||||
{
|
||||
return defaultTimeTrait ? defaultTimeTrait.duration : NaN;
|
||||
}
|
||||
|
||||
public function set defaultDuration(param1:Number) : void
|
||||
{
|
||||
if(isNaN(param1) || param1 < 0)
|
||||
{
|
||||
if(defaultTimeTrait != null)
|
||||
{
|
||||
removeTraitResolver("time");
|
||||
defaultTimeTrait = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(defaultTimeTrait == null)
|
||||
{
|
||||
defaultTimeTrait = new ModifiableTimeTrait();
|
||||
addTraitResolver("time",new DefaultTraitResolver("time",defaultTimeTrait));
|
||||
}
|
||||
defaultTimeTrait.duration = param1;
|
||||
}
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
loader = getLoaderForResource(param1,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 _loc1_:TimeTrait = null;
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc3_:SoundLoadTrait = null;
|
||||
var _loc5_:LoadTrait = getTrait("load") as LoadTrait;
|
||||
soundAdapter = null;
|
||||
stream = null;
|
||||
var _loc4_:NetStreamLoadTrait = _loc5_ as NetStreamLoadTrait;
|
||||
if(_loc4_)
|
||||
{
|
||||
stream = _loc4_.netStream;
|
||||
stream.addEventListener("netStatus",onNetStatusEvent);
|
||||
_loc4_.connection.addEventListener("netStatus",onNetStatusEvent,false,0,true);
|
||||
_loc2_ = false;
|
||||
if(loader is NetLoader)
|
||||
{
|
||||
_loc2_ = (loader as NetLoader).reconnectStreams;
|
||||
}
|
||||
addTrait("play",new NetStreamPlayTrait(stream,resource,_loc2_,_loc4_.connection));
|
||||
_loc1_ = new NetStreamTimeTrait(stream,resource,defaultDuration);
|
||||
addTrait("time",_loc1_);
|
||||
addTrait("seek",new NetStreamSeekTrait(_loc1_,_loc5_,stream));
|
||||
addTrait("audio",new NetStreamAudioTrait(stream));
|
||||
addTrait("buffer",new NetStreamBufferTrait(stream));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _loc5_ as SoundLoadTrait;
|
||||
soundAdapter = new SoundAdapter(this,_loc3_.sound);
|
||||
addTrait("play",new AudioPlayTrait(soundAdapter));
|
||||
_loc1_ = new AudioTimeTrait(soundAdapter);
|
||||
addTrait("time",_loc1_);
|
||||
addTrait("seek",new AudioSeekTrait(_loc1_,soundAdapter));
|
||||
addTrait("audio",new AudioAudioTrait(soundAdapter));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
if(stream != null)
|
||||
{
|
||||
stream.removeEventListener("netStatus",onNetStatusEvent);
|
||||
}
|
||||
var _loc1_:NetStreamLoadTrait = getTrait("load") as NetStreamLoadTrait;
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
_loc1_.connection.removeEventListener("netStatus",onNetStatusEvent);
|
||||
}
|
||||
removeTrait("play");
|
||||
removeTrait("seek");
|
||||
removeTrait("time");
|
||||
removeTrait("audio");
|
||||
removeTrait("buffer");
|
||||
if(soundAdapter != null)
|
||||
{
|
||||
soundAdapter.pause();
|
||||
}
|
||||
soundAdapter = null;
|
||||
stream = null;
|
||||
}
|
||||
|
||||
private function onNetStatusEvent(param1:NetStatusEvent) : void
|
||||
{
|
||||
var _loc2_:MediaError = null;
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case "NetStream.Play.Failed":
|
||||
case "NetStream.Failed":
|
||||
_loc2_ = new MediaError(15,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.StreamNotFound":
|
||||
_loc2_ = new MediaError(16,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.FileStructureInvalid":
|
||||
_loc2_ = new MediaError(17,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.NoSupportedTrackFound":
|
||||
_loc2_ = new MediaError(18,param1.info.description);
|
||||
break;
|
||||
case "NetConnection.Connect.IdleTimeOut":
|
||||
_loc2_ = new MediaError(14,param1.info.description);
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
|
||||
private function get alternateLoaders() : Vector.<LoaderBase>
|
||||
{
|
||||
if(_alternateLoaders == null)
|
||||
{
|
||||
_alternateLoaders = new Vector.<LoaderBase>();
|
||||
_alternateLoaders.push(new SoundLoader());
|
||||
_alternateLoaders.push(new NetLoader());
|
||||
}
|
||||
return _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,187 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
import flash.net.URLLoader;
|
||||
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.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.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
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();
|
||||
supportedMimeTypes.push("application/f4m+xml");
|
||||
if(param1 == null)
|
||||
{
|
||||
param1 = new DefaultMediaFactory();
|
||||
}
|
||||
this.parser = new ManifestParser();
|
||||
this.factory = param1;
|
||||
}
|
||||
|
||||
override public function canHandleResource(param1:MediaResourceBase) : Boolean
|
||||
{
|
||||
var _loc2_:URLResource = null;
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:int = MediaTypeUtil.checkMetadataMatchWithResource(param1,new Vector.<String>(),supportedMimeTypes);
|
||||
if(_loc4_ == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(param1 is URLResource)
|
||||
{
|
||||
_loc2_ = URLResource(param1);
|
||||
_loc3_ = new URL(_loc2_.url).extension;
|
||||
return _loc3_ == "f4m";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override protected function executeLoad(param1:LoadTrait) : void
|
||||
{
|
||||
var manifest:Manifest;
|
||||
var manifestLoader:URLLoader;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var onError:* = function(param1:ErrorEvent):void
|
||||
{
|
||||
manifestLoader.removeEventListener("complete",onComplete);
|
||||
manifestLoader.removeEventListener("ioError",onError);
|
||||
manifestLoader.removeEventListener("securityError",onError);
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(0,param1.text)));
|
||||
};
|
||||
var onComplete:* = function(param1:Event):void
|
||||
{
|
||||
var unfinishedLoads:Number;
|
||||
var item:DRMAdditionalHeader;
|
||||
var completionCallback:*;
|
||||
var event:Event = param1;
|
||||
manifestLoader.removeEventListener("complete",onComplete);
|
||||
manifestLoader.removeEventListener("ioError",onError);
|
||||
manifestLoader.removeEventListener("securityError",onError);
|
||||
try
|
||||
{
|
||||
manifest = parser.parse(event.target.data,getRootUrl(URLResource(loadTrait.resource).url));
|
||||
}
|
||||
catch(parseError:Error)
|
||||
{
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",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 = unfinishedLoads - 1;
|
||||
}
|
||||
if(unfinishedLoads == 0)
|
||||
{
|
||||
finishLoad();
|
||||
}
|
||||
};
|
||||
unfinishedLoads = unfinishedLoads + 1;
|
||||
loadAdditionalHeader(item,completionCallback,onError);
|
||||
}
|
||||
}
|
||||
if(unfinishedLoads == 0)
|
||||
{
|
||||
finishLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
var finishLoad:* = function():void
|
||||
{
|
||||
var _loc3_:MediaResourceBase = null;
|
||||
var _loc1_:MediaElement = null;
|
||||
var _loc2_:* = null;
|
||||
try
|
||||
{
|
||||
_loc3_ = parser.createResource(manifest,URLResource(loadTrait.resource));
|
||||
_loc1_ = factory.createMediaElement(_loc3_);
|
||||
if(_loc1_.hasOwnProperty("defaultDuration") && !isNaN(manifest.duration))
|
||||
{
|
||||
_loc1_["defaultDuration"] = manifest.duration;
|
||||
}
|
||||
LoadFromDocumentLoadTrait(loadTrait).mediaElement = _loc1_;
|
||||
updateLoadTrait(loadTrait,"ready");
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(23,error.message)));
|
||||
}
|
||||
};
|
||||
updateLoadTrait(loadTrait,"loading");
|
||||
manifestLoader = new URLLoader(new URLRequest(URLResource(loadTrait.resource).url));
|
||||
manifestLoader.addEventListener("complete",onComplete);
|
||||
manifestLoader.addEventListener("ioError",onError);
|
||||
manifestLoader.addEventListener("securityError",onError);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
updateLoadTrait(param1,"uninitialized");
|
||||
}
|
||||
|
||||
private function loadAdditionalHeader(param1:DRMAdditionalHeader, param2:Function, param3:Function) : void
|
||||
{
|
||||
var item:DRMAdditionalHeader = param1;
|
||||
var completionCallback:Function = param2;
|
||||
var onError:Function = param3;
|
||||
var onDRMLoadComplete:* = function(param1:Event):void
|
||||
{
|
||||
param1.target.removeEventListener("complete",onDRMLoadComplete);
|
||||
param1.target.removeEventListener("ioError",onError);
|
||||
param1.target.removeEventListener("securityError",onError);
|
||||
item.data = URLLoader(param1.target).data;
|
||||
completionCallback(true);
|
||||
};
|
||||
var drmLoader:URLLoader = new URLLoader();
|
||||
drmLoader.dataFormat = "binary";
|
||||
drmLoader.addEventListener("complete",onDRMLoadComplete);
|
||||
drmLoader.addEventListener("ioError",onError);
|
||||
drmLoader.addEventListener("securityError",onError);
|
||||
drmLoader.load(new URLRequest(HTTPStreamingUtils.normalizeURL(item.url)));
|
||||
}
|
||||
|
||||
private function getRootUrl(param1:String) : String
|
||||
{
|
||||
return param1.substr(0,param1.lastIndexOf("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
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;
|
||||
|
||||
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 _smoothing;
|
||||
}
|
||||
|
||||
public function set smoothing(param1:Boolean) : void
|
||||
{
|
||||
if(_smoothing != param1)
|
||||
{
|
||||
_smoothing = param1;
|
||||
applySmoothingSetting();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new LoaderLoadTrait(param2,param1);
|
||||
}
|
||||
|
||||
override protected function processReadyState() : void
|
||||
{
|
||||
var _loc1_:LoaderLoadTrait = getTrait("load") as LoaderLoadTrait;
|
||||
addTrait("displayObject",LoaderUtils.createDisplayObjectTrait(_loc1_.loader,this));
|
||||
applySmoothingSetting();
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
removeTrait("displayObject");
|
||||
}
|
||||
|
||||
private function applySmoothingSetting() : void
|
||||
{
|
||||
var _loc2_:Loader = null;
|
||||
var _loc3_:Bitmap = null;
|
||||
var _loc1_:DisplayObjectTrait = getTrait("displayObject") as DisplayObjectTrait;
|
||||
if(_loc1_)
|
||||
{
|
||||
_loc2_ = _loc1_.displayObject as Loader;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_loc3_ = _loc2_.content as Bitmap;
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.smoothing = _smoothing;
|
||||
}
|
||||
}
|
||||
catch(error:SecurityError)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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 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>(["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_ != 2)
|
||||
{
|
||||
return _loc2_ == 0;
|
||||
}
|
||||
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,checkPolicyFile);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.unloadLoadTrait(param1,updateLoadTrait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
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.utils.ByteArray;
|
||||
import org.osmf.events.DRMEvent;
|
||||
import org.osmf.events.MediaError;
|
||||
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.NetLoader;
|
||||
import org.osmf.net.NetStreamAudioTrait;
|
||||
import org.osmf.net.NetStreamBufferTrait;
|
||||
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.StreamingURLResource;
|
||||
import org.osmf.net.drm.NetStreamDRMTrait;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
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("invalidParam"));
|
||||
}
|
||||
}
|
||||
|
||||
public function get client() : NetClient
|
||||
{
|
||||
return stream != null ? stream.client as NetClient : null;
|
||||
}
|
||||
|
||||
public function get defaultDuration() : Number
|
||||
{
|
||||
return defaultTimeTrait ? defaultTimeTrait.duration : NaN;
|
||||
}
|
||||
|
||||
public function set defaultDuration(param1:Number) : void
|
||||
{
|
||||
if(isNaN(param1) || param1 < 0)
|
||||
{
|
||||
if(defaultTimeTrait != null)
|
||||
{
|
||||
removeTraitResolver("time");
|
||||
defaultTimeTrait = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(defaultTimeTrait == null)
|
||||
{
|
||||
defaultTimeTrait = new ModifiableTimeTrait();
|
||||
addTraitResolver("time",new DefaultTraitResolver("time",defaultTimeTrait));
|
||||
}
|
||||
defaultTimeTrait.duration = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get smoothing() : Boolean
|
||||
{
|
||||
return _smoothing;
|
||||
}
|
||||
|
||||
public function set smoothing(param1:Boolean) : void
|
||||
{
|
||||
_smoothing = param1;
|
||||
if(video != null)
|
||||
{
|
||||
video.smoothing = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get deblocking() : int
|
||||
{
|
||||
return _deblocking;
|
||||
}
|
||||
|
||||
public function set deblocking(param1:int) : void
|
||||
{
|
||||
_deblocking = param1;
|
||||
if(video != null)
|
||||
{
|
||||
video.deblocking = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function get currentFPS() : Number
|
||||
{
|
||||
return stream != null ? 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_:ByteArray = null;
|
||||
var _loc3_:NetStreamLoadTrait = getTrait("load") as NetStreamLoadTrait;
|
||||
stream = _loc3_.netStream;
|
||||
video = createVideo();
|
||||
video.smoothing = _smoothing;
|
||||
video.deblocking = _deblocking;
|
||||
video.width = video.height = 0;
|
||||
video.attachNetStream(stream);
|
||||
NetClient(stream.client).addHandler("onMetaData",onMetaData);
|
||||
NetClient(stream.client).addHandler("onCuePoint",onCuePoint);
|
||||
stream.addEventListener("netStatus",onNetStatusEvent);
|
||||
_loc3_.connection.addEventListener("netStatus",onNetStatusEvent,false,0,true);
|
||||
stream.addEventListener("drmError",onDRMErrorEvent);
|
||||
var _loc1_:StreamingURLResource = resource as StreamingURLResource;
|
||||
if(_loc1_ != null && _loc1_.drmContentData)
|
||||
{
|
||||
_loc2_ = _loc1_.drmContentData;
|
||||
setupDRMTrait(_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.addEventListener("status",onStatus);
|
||||
stream.addEventListener("drmStatus",onDRMStatus);
|
||||
}
|
||||
finishLoad();
|
||||
}
|
||||
|
||||
private function onStatus(param1:StatusEvent) : void
|
||||
{
|
||||
if(param1.code == "DRM.encryptedFLV" && getTrait("drm") == null)
|
||||
{
|
||||
createDRMTrait();
|
||||
}
|
||||
}
|
||||
|
||||
private function onDRMStatus(param1:DRMStatusEvent) : void
|
||||
{
|
||||
drmTrait.inlineOnVoucher(param1);
|
||||
}
|
||||
|
||||
private function reloadAfterAuth(param1:DRMEvent) : void
|
||||
{
|
||||
var _loc2_:NetStreamLoadTrait = null;
|
||||
if(drmTrait.drmState == "authenticationComplete")
|
||||
{
|
||||
_loc2_ = getTrait("load") as NetStreamLoadTrait;
|
||||
if(_loc2_.loadState == "ready")
|
||||
{
|
||||
_loc2_.unload();
|
||||
}
|
||||
_loc2_.load();
|
||||
}
|
||||
}
|
||||
|
||||
private function createDRMTrait() : void
|
||||
{
|
||||
drmTrait = new NetStreamDRMTrait();
|
||||
addTrait("drm",drmTrait);
|
||||
}
|
||||
|
||||
private function setupDRMTrait(param1:ByteArray) : void
|
||||
{
|
||||
createDRMTrait();
|
||||
drmTrait.drmMetadata = param1;
|
||||
}
|
||||
|
||||
private function onDRMErrorEvent(param1:DRMErrorEvent) : void
|
||||
{
|
||||
if(param1.errorID == 3330)
|
||||
{
|
||||
drmTrait.addEventListener("drmStateChange",reloadAfterAuth);
|
||||
drmTrait.drmMetadata = param1.contentData;
|
||||
}
|
||||
else if(param1.drmUpdateNeeded)
|
||||
{
|
||||
update("drm");
|
||||
}
|
||||
else if(param1.systemUpdateNeeded)
|
||||
{
|
||||
update("system");
|
||||
}
|
||||
else
|
||||
{
|
||||
drmTrait.inlineDRMFailed(new MediaError(param1.errorID));
|
||||
}
|
||||
}
|
||||
|
||||
private function update(param1:String) : void
|
||||
{
|
||||
if(drmTrait == null)
|
||||
{
|
||||
createDRMTrait();
|
||||
}
|
||||
var _loc2_:SystemUpdater = drmTrait.update(param1);
|
||||
_loc2_.addEventListener("complete",onUpdateComplete);
|
||||
}
|
||||
|
||||
private function finishLoad() : void
|
||||
{
|
||||
var timeTrait:TimeTrait;
|
||||
var reconnectStreams:Boolean;
|
||||
var onDurationChange:*;
|
||||
var dsResource:DynamicStreamingResource;
|
||||
var dsTrait:MediaTraitBase;
|
||||
var loadTrait:NetStreamLoadTrait = getTrait("load") as NetStreamLoadTrait;
|
||||
var trait:MediaTraitBase = loadTrait.getTrait("dvr");
|
||||
if(trait != null)
|
||||
{
|
||||
addTrait("dvr",trait);
|
||||
}
|
||||
trait = loadTrait.getTrait("audio");
|
||||
addTrait("audio",trait || new NetStreamAudioTrait(stream));
|
||||
trait = loadTrait.getTrait("buffer");
|
||||
addTrait("buffer",trait || new NetStreamBufferTrait(stream));
|
||||
timeTrait = (trait = loadTrait.getTrait("time")) as TimeTrait;
|
||||
if(timeTrait == null)
|
||||
{
|
||||
timeTrait = new NetStreamTimeTrait(stream,loadTrait.resource,defaultDuration);
|
||||
}
|
||||
addTrait("time",timeTrait);
|
||||
trait = loadTrait.getTrait("displayObject");
|
||||
addTrait("displayObject",trait || new NetStreamDisplayObjectTrait(stream,video,NaN,NaN));
|
||||
trait = loadTrait.getTrait("play");
|
||||
reconnectStreams = false;
|
||||
reconnectStreams = (loader as NetLoader).reconnectStreams;
|
||||
addTrait("play",trait || new NetStreamPlayTrait(stream,resource,reconnectStreams,loadTrait.connection));
|
||||
trait = loadTrait.getTrait("seek");
|
||||
if(trait == null && NetStreamUtils.getStreamType(resource) != "live")
|
||||
{
|
||||
trait = new NetStreamSeekTrait(timeTrait,loadTrait,stream,video);
|
||||
}
|
||||
if(trait != null)
|
||||
{
|
||||
if(isNaN(timeTrait.duration) || timeTrait.duration == 0)
|
||||
{
|
||||
onDurationChange = function(param1:TimeEvent):void
|
||||
{
|
||||
timeTrait.removeEventListener("durationChange",onDurationChange);
|
||||
addTrait("seek",trait);
|
||||
};
|
||||
timeTrait.addEventListener("durationChange",onDurationChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
addTrait("seek",trait);
|
||||
}
|
||||
}
|
||||
dsResource = resource as DynamicStreamingResource;
|
||||
if(dsResource != null && loadTrait.switchManager != null)
|
||||
{
|
||||
dsTrait = loadTrait.getTrait("dynamicStream");
|
||||
addTrait("dynamicStream",dsTrait || new NetStreamDynamicStreamTrait(stream,loadTrait.switchManager,dsResource));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
var _loc1_:NetStreamLoadTrait = getTrait("load") as NetStreamLoadTrait;
|
||||
NetClient(stream.client).removeHandler("onMetaData",onMetaData);
|
||||
stream.removeEventListener("netStatus",onNetStatusEvent);
|
||||
_loc1_.connection.removeEventListener("netStatus",onNetStatusEvent);
|
||||
removeTrait("audio");
|
||||
removeTrait("buffer");
|
||||
removeTrait("play");
|
||||
removeTrait("time");
|
||||
removeTrait("displayObject");
|
||||
removeTrait("seek");
|
||||
removeTrait("dynamicStream");
|
||||
removeTrait("dvr");
|
||||
stream.removeEventListener("drmError",onDRMErrorEvent);
|
||||
stream.removeEventListener("drmStatus",onDRMStatus);
|
||||
stream.removeEventListener("status",onStatus);
|
||||
if(drmTrait != null)
|
||||
{
|
||||
drmTrait.removeEventListener("drmStateChange",reloadAfterAuth);
|
||||
removeTrait("drm");
|
||||
drmTrait = null;
|
||||
}
|
||||
video.attachNetStream(null);
|
||||
stream = null;
|
||||
video = null;
|
||||
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("http://www.osmf.org/timeline/dynamicCuePoints/1.0") as TimelineMetadata;
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
_loc3_ = new TimelineMetadata(this);
|
||||
addMetadata("http://www.osmf.org/timeline/dynamicCuePoints/1.0",_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(embeddedCuePoints == null)
|
||||
{
|
||||
embeddedCuePoints = new TimelineMetadata(this);
|
||||
addMetadata("http://www.osmf.org/timeline/embeddedCuePoints/1.0",embeddedCuePoints);
|
||||
}
|
||||
var _loc2_:CuePoint = new CuePoint(param1.type,param1.time,param1.name,param1.parameters);
|
||||
try
|
||||
{
|
||||
embeddedCuePoints.addMarker(_loc2_);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private function onUpdateComplete(param1:Event) : void
|
||||
{
|
||||
(getTrait("load") as LoadTrait).unload();
|
||||
(getTrait("load") as LoadTrait).load();
|
||||
}
|
||||
|
||||
private function onNetStatusEvent(param1:NetStatusEvent) : void
|
||||
{
|
||||
var _loc2_:MediaError = null;
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case "NetStream.Play.Failed":
|
||||
case "NetStream.Failed":
|
||||
_loc2_ = new MediaError(15,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.StreamNotFound":
|
||||
_loc2_ = new MediaError(16,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.FileStructureInvalid":
|
||||
_loc2_ = new MediaError(17,param1.info.description);
|
||||
break;
|
||||
case "NetStream.Play.NoSupportedTrackFound":
|
||||
_loc2_ = new MediaError(18,param1.info.description);
|
||||
break;
|
||||
case "NetConnection.Connect.IdleTimeOut":
|
||||
_loc2_ = new MediaError(14,param1.info.description);
|
||||
}
|
||||
if(param1.info.code == "DRM.UpdateNeeded")
|
||||
{
|
||||
update("drm");
|
||||
}
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
dispatchEvent(new MediaErrorEvent("mediaError",false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
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.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
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("nullParam"));
|
||||
}
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
if(_resource != param1 && param1 != null)
|
||||
{
|
||||
_resource = param1;
|
||||
loadTrait = new LoadFromDocumentLoadTrait(loader,resource);
|
||||
loadTrait.addEventListener("loadStateChange",onLoadStateChange,false,2147483647);
|
||||
if(super.getTrait("load") != null)
|
||||
{
|
||||
super.removeTrait("load");
|
||||
}
|
||||
super.addTrait("load",loadTrait);
|
||||
}
|
||||
}
|
||||
|
||||
override public function get resource() : MediaResourceBase
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
private function onLoaderStateChange(param1:Event) : void
|
||||
{
|
||||
removeTrait("load");
|
||||
proxiedElement = loadTrait.mediaElement;
|
||||
}
|
||||
|
||||
private function onLoadStateChange(param1:LoadEvent) : void
|
||||
{
|
||||
var proxiedLoadTrait:LoadTrait;
|
||||
var onProxiedElementLoadStateChange:*;
|
||||
var event:LoadEvent = param1;
|
||||
if(event.loadState == "ready")
|
||||
{
|
||||
onProxiedElementLoadStateChange = function(param1:LoadEvent):void
|
||||
{
|
||||
if(param1.loadState == "loading")
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
}
|
||||
else
|
||||
{
|
||||
proxiedLoadTrait.removeEventListener("loadStateChange",onProxiedElementLoadStateChange);
|
||||
}
|
||||
};
|
||||
event.stopImmediatePropagation();
|
||||
removeTrait("load");
|
||||
proxiedLoadTrait = loadTrait.mediaElement.getTrait("load") as LoadTrait;
|
||||
proxiedLoadTrait.addEventListener("loadStateChange",onProxiedElementLoadStateChange,false,2147483647);
|
||||
proxiedElement = loadTrait.mediaElement;
|
||||
if(proxiedLoadTrait.loadState == "uninitialized")
|
||||
{
|
||||
proxiedLoadTrait.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
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("traitAdd",onProxyTraitAdd,false,2147483647);
|
||||
this.addEventListener("traitRemove",onProxyTraitRemove,false,2147483647);
|
||||
this.addEventListener("containerChange",onProxyContainerChange);
|
||||
this.proxiedElement = param1;
|
||||
}
|
||||
|
||||
public function get proxiedElement() : MediaElement
|
||||
{
|
||||
return _proxiedElement;
|
||||
}
|
||||
|
||||
public function set proxiedElement(param1:MediaElement) : void
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
if(param1 != _proxiedElement)
|
||||
{
|
||||
if(_proxiedElement != null)
|
||||
{
|
||||
toggleMediaElementListeners(_proxiedElement,false);
|
||||
for each(_loc2_ in _proxiedElement.traitTypes)
|
||||
{
|
||||
if(super.hasTrait(_loc2_) == false && (_blockedTraits == null || _blockedTraits.indexOf(_loc2_) == -1))
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent("traitRemove",false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
_proxiedElement = param1;
|
||||
if(_proxiedElement != null)
|
||||
{
|
||||
ProxyMetadata(metadata).metadata = _proxiedElement.metadata;
|
||||
_proxiedElement.dispatchEvent(new ContainerChangeEvent("containerChange",false,false,_proxiedElement.container,container));
|
||||
toggleMediaElementListeners(_proxiedElement,true);
|
||||
for each(_loc2_ in _proxiedElement.traitTypes)
|
||||
{
|
||||
if(super.hasTrait(_loc2_) == false && (_blockedTraits == null || _blockedTraits.indexOf(_loc2_) == -1))
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent("traitAdd",false,false,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function get traitTypes() : Vector.<String>
|
||||
{
|
||||
var _loc2_:Vector.<String> = new Vector.<String>();
|
||||
for each(var _loc1_:String in MediaTraitType.ALL_TYPES)
|
||||
{
|
||||
if(hasTrait(_loc1_))
|
||||
{
|
||||
_loc2_.push(_loc1_);
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override public function hasTrait(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return getTrait(param1) != null;
|
||||
}
|
||||
|
||||
override public function getTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:MediaTraitBase = null;
|
||||
if(blocksTrait(param1) == false)
|
||||
{
|
||||
_loc2_ = super.getTrait(param1) || (proxiedElement != null ? proxiedElement.getTrait(param1) : null);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override public function get resource() : MediaResourceBase
|
||||
{
|
||||
return proxiedElement ? proxiedElement.resource : null;
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
if(proxiedElement != null)
|
||||
{
|
||||
proxiedElement.resource = param1;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function addTrait(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(blocksTrait(param1) == false && proxiedElement != null && proxiedElement.hasTrait(param1) == true)
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent("traitRemove",false,false,param1));
|
||||
}
|
||||
super.addTrait(param1,param2);
|
||||
}
|
||||
|
||||
override protected function removeTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
var _loc2_:MediaTraitBase = super.removeTrait(param1);
|
||||
if(blocksTrait(param1) == false && proxiedElement != null && proxiedElement.hasTrait(param1) == true)
|
||||
{
|
||||
super.dispatchEvent(new MediaElementEvent("traitAdd",false,false,param1));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
override protected function createMetadata() : Metadata
|
||||
{
|
||||
return new ProxyMetadata();
|
||||
}
|
||||
|
||||
final protected function get blockedTraits() : Vector.<String>
|
||||
{
|
||||
if(_blockedTraits == null)
|
||||
{
|
||||
_blockedTraits = new Vector.<String>();
|
||||
}
|
||||
return _blockedTraits;
|
||||
}
|
||||
|
||||
final protected function set blockedTraits(param1:Vector.<String>) : void
|
||||
{
|
||||
var _loc4_:* = null;
|
||||
if(param1 == _blockedTraits)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:Array = [];
|
||||
var _loc2_:Array = [];
|
||||
if(_proxiedElement != null)
|
||||
{
|
||||
for each(_loc4_ in MediaTraitType.ALL_TYPES)
|
||||
{
|
||||
if(param1.indexOf(_loc4_) != -1)
|
||||
{
|
||||
if(_blockedTraits == null || _blockedTraits.indexOf(_loc4_) == -1)
|
||||
{
|
||||
_loc3_.push(_loc4_);
|
||||
}
|
||||
}
|
||||
else if(_blockedTraits != null && _blockedTraits.indexOf(_loc4_) != -1)
|
||||
{
|
||||
_loc2_.push(_loc4_);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_proxiedElement != null)
|
||||
{
|
||||
for each(_loc4_ in _loc3_)
|
||||
{
|
||||
if(proxiedElement.hasTrait(_loc4_) || Boolean(super.hasTrait(_loc4_)))
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("traitRemove",false,false,_loc4_));
|
||||
}
|
||||
}
|
||||
_blockedTraits = param1;
|
||||
for each(_loc4_ in _loc2_)
|
||||
{
|
||||
if(proxiedElement.hasTrait(_loc4_) || Boolean(super.hasTrait(_loc4_)))
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("traitAdd",false,false,_loc4_));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_blockedTraits = param1;
|
||||
}
|
||||
}
|
||||
|
||||
private function toggleMediaElementListeners(param1:MediaElement, param2:Boolean) : void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_proxiedElement.addEventListener("mediaError",onMediaError);
|
||||
_proxiedElement.addEventListener("traitAdd",onTraitAdd);
|
||||
_proxiedElement.addEventListener("traitRemove",onTraitRemove);
|
||||
_proxiedElement.addEventListener("metadataAdd",onMetadataEvent);
|
||||
_proxiedElement.addEventListener("metadataRemove",onMetadataEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
_proxiedElement.removeEventListener("mediaError",onMediaError);
|
||||
_proxiedElement.removeEventListener("traitAdd",onTraitAdd);
|
||||
_proxiedElement.removeEventListener("traitRemove",onTraitRemove);
|
||||
_proxiedElement.removeEventListener("metadataAdd",onMetadataEvent);
|
||||
_proxiedElement.removeEventListener("metadataRemove",onMetadataEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaError(param1:MediaErrorEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onTraitAdd(param1:MediaElementEvent) : void
|
||||
{
|
||||
processTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onTraitRemove(param1:MediaElementEvent) : void
|
||||
{
|
||||
processTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onMetadataEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onProxyContainerChange(param1:ContainerChangeEvent) : void
|
||||
{
|
||||
if(proxiedElement != null)
|
||||
{
|
||||
proxiedElement.dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
private function onProxyTraitAdd(param1:MediaElementEvent) : void
|
||||
{
|
||||
processProxyTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function onProxyTraitRemove(param1:MediaElementEvent) : void
|
||||
{
|
||||
processProxyTraitsChangeEvent(param1);
|
||||
}
|
||||
|
||||
private function processTraitsChangeEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(blocksTrait(param1.traitType) == false && super.hasTrait(param1.traitType) == false)
|
||||
{
|
||||
super.dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
private function processProxyTraitsChangeEvent(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(blocksTrait(param1.traitType) == true)
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
private function blocksTrait(param1:String) : Boolean
|
||||
{
|
||||
return _blockedTraits && _blockedTraits.indexOf(param1) != -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
|
||||
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("load") as LoaderLoadTrait;
|
||||
addTrait("displayObject",LoaderUtils.createDisplayObjectTrait(_loc1_.loader,this));
|
||||
}
|
||||
|
||||
override protected function processUnloadingState() : void
|
||||
{
|
||||
removeTrait("displayObject");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.osmf.elements
|
||||
{
|
||||
import org.osmf.elements.loaderClasses.LoaderUtils;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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>(["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_ != 2)
|
||||
{
|
||||
return _loc2_ == 0;
|
||||
}
|
||||
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,useCurrentSecurityDomain,false,validateLoadedContentFunction);
|
||||
}
|
||||
|
||||
override protected function executeUnload(param1:LoadTrait) : void
|
||||
{
|
||||
LoaderUtils.unloadLoadTrait(param1,updateLoadTrait);
|
||||
}
|
||||
|
||||
public function get validateLoadedContentFunction() : Function
|
||||
{
|
||||
return allowValidationOfLoadedContent ? _validateLoadedContentFunction : null;
|
||||
}
|
||||
|
||||
public function set validateLoadedContentFunction(param1:Function) : void
|
||||
{
|
||||
_validateLoadedContentFunction = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
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.MediaErrorEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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 SoundLoader extends LoaderBase
|
||||
{
|
||||
|
||||
private static const MIN_BYTES_TO_RECEIVE:int = 16;
|
||||
|
||||
private static const MIME_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["audio/mpeg"]);
|
||||
|
||||
private static const MEDIA_TYPES_SUPPORTED:Vector.<String> = Vector.<String>(["audio"]);
|
||||
|
||||
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_ != 2)
|
||||
{
|
||||
return _loc2_ == 0;
|
||||
}
|
||||
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 sound:Sound;
|
||||
var urlRequest:URLRequest;
|
||||
var context:SoundLoaderContext;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var toggleSoundListeners:* = function(param1:Sound, param2:Boolean):void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.addEventListener("progress",onProgress);
|
||||
param1.addEventListener("ioError",onIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.removeEventListener("progress",onProgress);
|
||||
param1.removeEventListener("ioError",onIOError);
|
||||
}
|
||||
};
|
||||
var onProgress:* = function(param1:ProgressEvent):void
|
||||
{
|
||||
if(param1.bytesTotal >= 16 && soundLoadTrait.loadState == "loading")
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
soundLoadTrait.sound = sound;
|
||||
updateLoadTrait(soundLoadTrait,"ready");
|
||||
}
|
||||
};
|
||||
var onIOError:* = function(param1:IOErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1,param1 ? param1.text : param2)));
|
||||
};
|
||||
var handleSecurityError:* = function(param1:String):void
|
||||
{
|
||||
toggleSoundListeners(sound,false);
|
||||
updateLoadTrait(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2,param1)));
|
||||
};
|
||||
var soundLoadTrait:SoundLoadTrait = loadTrait as SoundLoadTrait;
|
||||
updateLoadTrait(soundLoadTrait,"loading");
|
||||
sound = new Sound();
|
||||
toggleSoundListeners(sound,true);
|
||||
urlRequest = new URLRequest((soundLoadTrait.resource as URLResource).url.toString());
|
||||
context = new SoundLoaderContext(1000,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_,"unloading");
|
||||
try
|
||||
{
|
||||
if(_loc2_.sound != null)
|
||||
{
|
||||
_loc2_.sound.close();
|
||||
}
|
||||
}
|
||||
catch(error:IOError)
|
||||
{
|
||||
}
|
||||
updateLoadTrait(_loc2_,"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,alternateLoaders);
|
||||
super.resource = param1;
|
||||
}
|
||||
|
||||
private function get alternateLoaders() : Vector.<LoaderBase>
|
||||
{
|
||||
if(_alternateLoaders == null)
|
||||
{
|
||||
_alternateLoaders = new Vector.<LoaderBase>();
|
||||
_alternateLoaders.push(new HTTPStreamingNetLoader());
|
||||
_alternateLoaders.push(new RTMPDynamicStreamingNetLoader());
|
||||
_alternateLoaders.push(new NetLoader());
|
||||
}
|
||||
return _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 = soundAdapter.soundTransform;
|
||||
_loc2_.volume = muted ? 0 : param1;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function mutedChangeStart(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = soundAdapter.soundTransform;
|
||||
_loc2_.volume = param1 ? 0 : volume;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function panChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = soundAdapter.soundTransform;
|
||||
_loc2_.pan = param1;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
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("complete",onPlaybackComplete,false,1,true);
|
||||
}
|
||||
|
||||
override protected function playStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "playing")
|
||||
{
|
||||
lastPlayFailed = !soundAdapter.play();
|
||||
}
|
||||
else if(param1 == "paused")
|
||||
{
|
||||
soundAdapter.pause();
|
||||
}
|
||||
else if(param1 == "stopped")
|
||||
{
|
||||
soundAdapter.stop();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function playStateChangeEnd() : void
|
||||
{
|
||||
if(lastPlayFailed)
|
||||
{
|
||||
stop();
|
||||
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)
|
||||
{
|
||||
soundAdapter.seek(param2);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function seekingChangeEnd(param1:Number) : void
|
||||
{
|
||||
super.seekingChangeEnd(param1);
|
||||
if(seeking == true)
|
||||
{
|
||||
setSeeking(false,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
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("progress",onDownloadProgress,false,0,true);
|
||||
param1.addEventListener("downloadComplete",onDownloadComplete,false,0,true);
|
||||
param1.addEventListener("complete",onPlaybackComplete,false,0,true);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return soundAdapter.currentTime;
|
||||
}
|
||||
|
||||
private function onDownloadProgress(param1:Event) : void
|
||||
{
|
||||
if(!isNaN(soundAdapter.estimatedDuration) && soundAdapter.estimatedDuration > 0)
|
||||
{
|
||||
soundAdapter.removeEventListener("progress",onDownloadProgress);
|
||||
setDuration(soundAdapter.estimatedDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
setDuration(soundAdapter.estimatedDuration);
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
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.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;
|
||||
_soundTransform = new SoundTransform();
|
||||
param2.addEventListener("complete",onDownloadComplete,false,0,true);
|
||||
param2.addEventListener("progress",onProgress,false,0,true);
|
||||
param2.addEventListener("ioError",onIOError,false,0,true);
|
||||
}
|
||||
|
||||
public function get currentTime() : Number
|
||||
{
|
||||
return channel != null ? channel.position / 1000 : lastStartTime / 1000;
|
||||
}
|
||||
|
||||
public function get estimatedDuration() : Number
|
||||
{
|
||||
return sound.length / (1000 * sound.bytesLoaded / sound.bytesTotal);
|
||||
}
|
||||
|
||||
public function get soundTransform() : SoundTransform
|
||||
{
|
||||
return _soundTransform;
|
||||
}
|
||||
|
||||
public function set soundTransform(param1:SoundTransform) : void
|
||||
{
|
||||
_soundTransform = param1;
|
||||
if(channel != null)
|
||||
{
|
||||
channel.soundTransform = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function play(param1:Number = -1) : Boolean
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
if(channel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = sound.play(param1 != -1 ? param1 : lastStartTime);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
channel = null;
|
||||
}
|
||||
if(channel != null)
|
||||
{
|
||||
playing = true;
|
||||
channel.soundTransform = _soundTransform;
|
||||
channel.addEventListener("soundComplete",onSoundComplete);
|
||||
_loc2_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
owner.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(10)));
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
lastStartTime = channel.position;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
lastStartTime = 0;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function seek(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Boolean = playing;
|
||||
if(channel != null)
|
||||
{
|
||||
clearChannel();
|
||||
}
|
||||
play(param1 * 1000);
|
||||
if(_loc2_ == false)
|
||||
{
|
||||
pause();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearChannel() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
channel.removeEventListener("soundComplete",onSoundComplete);
|
||||
channel.stop();
|
||||
channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSoundComplete(param1:Event) : void
|
||||
{
|
||||
lastStartTime = channel.position;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
dispatchEvent(new Event("complete"));
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(new Event("downloadComplete"));
|
||||
}
|
||||
|
||||
private function onProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
owner.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.media.Sound;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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 _sound;
|
||||
}
|
||||
|
||||
public function set sound(param1:Sound) : void
|
||||
{
|
||||
_sound = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "ready")
|
||||
{
|
||||
if(_sound != null)
|
||||
{
|
||||
_sound.addEventListener("open",bytesTotalCheckingHandler,false,0,true);
|
||||
_sound.addEventListener("progress",bytesTotalCheckingHandler,false,0,true);
|
||||
}
|
||||
}
|
||||
else if(param1 == "uninitialized")
|
||||
{
|
||||
_sound = null;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get bytesLoaded() : Number
|
||||
{
|
||||
return _sound ? _sound.bytesLoaded : NaN;
|
||||
}
|
||||
|
||||
override public function get bytesTotal() : Number
|
||||
{
|
||||
return _sound ? _sound.bytesTotal : NaN;
|
||||
}
|
||||
|
||||
private function bytesTotalCheckingHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoadEvent = null;
|
||||
if(lastBytesTotal != _sound.bytesTotal)
|
||||
{
|
||||
_loc2_ = new LoadEvent("bytesTotalChange",false,false,null,_sound.bytesTotal);
|
||||
lastBytesTotal = _sound.bytesTotal;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
data = new ByteArray();
|
||||
}
|
||||
|
||||
private static function copyByteArray(param1:ByteArray, param2:ByteArray, param3:uint = 0) : void
|
||||
{
|
||||
var _loc5_:int = int(param1.position);
|
||||
param1.position = 0;
|
||||
param2.position = 0;
|
||||
var _loc4_:uint = 0;
|
||||
while(param1.bytesAvailable > 0 && _loc4_ < param3)
|
||||
{
|
||||
param2.writeByte(param1.readByte());
|
||||
_loc4_++;
|
||||
}
|
||||
param1.position = _loc5_;
|
||||
param2.position = 0;
|
||||
}
|
||||
|
||||
public function decode(param1:String) : void
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc2_:Number = NaN;
|
||||
_loc3_ = 0;
|
||||
for(; _loc3_ < param1.length; _loc3_++)
|
||||
{
|
||||
_loc2_ = param1.charCodeAt(_loc3_);
|
||||
if(_loc2_ == 61)
|
||||
{
|
||||
work[count++] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(inverse[_loc2_] == 64)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
work[count++] = inverse[_loc2_];
|
||||
}
|
||||
if(count == 4)
|
||||
{
|
||||
count = 0;
|
||||
data.writeByte(work[0] << 2 | (work[1] & 0xFF) >> 4);
|
||||
filled = filled + 1;
|
||||
if(work[2] == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
data.writeByte(work[1] << 4 | (work[2] & 0xFF) >> 2);
|
||||
filled = filled + 1;
|
||||
if(work[3] == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
data.writeByte(work[2] << 6 | work[3]);
|
||||
filled = filled + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function drain() : ByteArray
|
||||
{
|
||||
var _loc1_:ByteArray = new ByteArray();
|
||||
copyByteArray(data,_loc1_,filled);
|
||||
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,88 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
internal class DateUtil
|
||||
{
|
||||
|
||||
public function DateUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function parseW3CDTF(param1:String) : Date
|
||||
{
|
||||
var _loc3_:Date = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc13_:String = null;
|
||||
var _loc18_:Array = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc21_:String = null;
|
||||
var _loc20_:Array = null;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc15_:Array = null;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc6_:String = null;
|
||||
try
|
||||
{
|
||||
_loc7_ = param1.substring(0,param1.indexOf("T"));
|
||||
_loc13_ = param1.substring(param1.indexOf("T") + 1,param1.length);
|
||||
_loc18_ = _loc7_.split("-");
|
||||
_loc9_ = _loc18_.shift();
|
||||
_loc16_ = _loc18_.shift();
|
||||
_loc2_ = _loc18_.shift();
|
||||
if(_loc13_.indexOf("Z") != -1)
|
||||
{
|
||||
_loc11_ = 1;
|
||||
_loc19_ = 0;
|
||||
_loc5_ = 0;
|
||||
_loc13_ = _loc13_.replace("Z","");
|
||||
}
|
||||
else if(_loc13_.indexOf("+") != -1)
|
||||
{
|
||||
_loc11_ = 1;
|
||||
_loc21_ = _loc13_.substring(_loc13_.indexOf("+") + 1,_loc13_.length);
|
||||
_loc19_ = Number(_loc21_.substring(0,_loc21_.indexOf(":")));
|
||||
_loc5_ = Number(_loc21_.substring(_loc21_.indexOf(":") + 1,_loc21_.length));
|
||||
_loc13_ = _loc13_.substring(0,_loc13_.indexOf("+"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_ = -1;
|
||||
_loc21_ = _loc13_.substring(_loc13_.indexOf("-") + 1,_loc13_.length);
|
||||
_loc19_ = Number(_loc21_.substring(0,_loc21_.indexOf(":")));
|
||||
_loc5_ = Number(_loc21_.substring(_loc21_.indexOf(":") + 1,_loc21_.length));
|
||||
_loc13_ = _loc13_.substring(0,_loc13_.indexOf("-"));
|
||||
}
|
||||
_loc20_ = _loc13_.split(":");
|
||||
_loc17_ = _loc20_.shift();
|
||||
_loc12_ = _loc20_.shift();
|
||||
_loc15_ = _loc20_.length > 0 ? String(_loc20_.shift()).split(".") : null;
|
||||
_loc14_ = _loc15_ != null && _loc15_.length > 0 ? Number(_loc15_.shift()) : 0;
|
||||
_loc4_ = _loc15_ != null && _loc15_.length > 0 ? Number(_loc15_.shift()) : 0;
|
||||
_loc10_ = Date.UTC(_loc9_,_loc16_ - 1,_loc2_,_loc17_,_loc12_,_loc14_,_loc4_);
|
||||
_loc8_ = (_loc19_ * 3600000 + _loc5_ * 60000) * _loc11_;
|
||||
_loc3_ = new Date(_loc10_ - _loc8_);
|
||||
if(_loc3_.toString() == "Invalid Date")
|
||||
{
|
||||
throw new Error("This date does not conform to W3CDTF.");
|
||||
}
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_loc6_ = "Unable to parse the string [" + param1 + "] into a date. ";
|
||||
_loc6_ = _loc6_ + ("The internal error was: " + e.toString());
|
||||
throw new Error(_loc6_);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,589 @@
|
||||
package org.osmf.elements.f4mClasses
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.net.DynamicStreamingItem;
|
||||
import org.osmf.net.DynamicStreamingResource;
|
||||
import org.osmf.net.MulticastResource;
|
||||
import org.osmf.net.NetStreamUtils;
|
||||
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
|
||||
{
|
||||
|
||||
private namespace xmlns = "http://ns.adobe.com/f4m/1.0";
|
||||
|
||||
public function ManifestParser()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function parse(param1:String, param2:String = null) : Manifest
|
||||
{
|
||||
var _loc10_:Media = null;
|
||||
var _loc5_:Manifest = new Manifest();
|
||||
var _loc12_:Boolean = false;
|
||||
var _loc9_:XML = new XML(param1);
|
||||
if(_loc9_.id.length() > 0)
|
||||
{
|
||||
_loc5_.id = _loc9_.id.text();
|
||||
}
|
||||
if(_loc9_.duration.length() > 0)
|
||||
{
|
||||
_loc5_.duration = _loc9_.duration.text();
|
||||
}
|
||||
if(_loc9_.startTime.length() > 0)
|
||||
{
|
||||
_loc5_.startTime = DateUtil.parseW3CDTF(_loc9_.startTime.text());
|
||||
}
|
||||
if(_loc9_.mimeType.length() > 0)
|
||||
{
|
||||
_loc5_.mimeType = _loc9_.mimeType.text();
|
||||
}
|
||||
if(_loc9_.streamType.length() > 0)
|
||||
{
|
||||
_loc5_.streamType = _loc9_.streamType.text();
|
||||
}
|
||||
if(_loc9_.deliveryType.length() > 0)
|
||||
{
|
||||
_loc5_.deliveryType = _loc9_.deliveryType.text();
|
||||
}
|
||||
if(_loc9_.baseURL.length() > 0)
|
||||
{
|
||||
_loc5_.baseURL = _loc9_.baseURL.text();
|
||||
}
|
||||
if(_loc9_.urlIncludesFMSApplicationInstance.length() > 0)
|
||||
{
|
||||
_loc5_.urlIncludesFMSApplicationInstance = _loc9_.urlIncludesFMSApplicationInstance.text() == "true";
|
||||
}
|
||||
var _loc8_:String = _loc5_.baseURL != null ? _loc5_.baseURL : param2;
|
||||
var _loc15_:int = 0;
|
||||
var _loc14_:XMLList = _loc9_.dvrInfo;
|
||||
for each(var _loc11_:XML in _loc14_)
|
||||
{
|
||||
parseDVRInfo(_loc11_,_loc8_,_loc5_);
|
||||
}
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc3_:Boolean = false;
|
||||
for each(var _loc7_:XML in _loc9_.media)
|
||||
{
|
||||
_loc10_ = parseMedia(_loc7_,_loc8_);
|
||||
if(_loc10_.multicastGroupspec != null && _loc10_.multicastGroupspec.length > 0 && (_loc10_.multicastStreamName == null || _loc10_.multicastStreamName.length <= 0) || _loc10_.multicastStreamName != null && _loc10_.multicastStreamName.length > 0 && (_loc10_.multicastGroupspec == null || _loc10_.multicastGroupspec.length <= 0))
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
if(_loc10_.multicastGroupspec != null && _loc10_.multicastGroupspec.length > 0)
|
||||
{
|
||||
_loc12_ = true;
|
||||
}
|
||||
_loc5_.media.push(_loc10_);
|
||||
if(!_loc6_)
|
||||
{
|
||||
_loc6_ = isNaN(_loc10_.bitrate);
|
||||
}
|
||||
}
|
||||
if(_loc3_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("multicastParameterInvalid"));
|
||||
}
|
||||
if(_loc5_.media.length > 1 && _loc12_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("multicastNotSupportMBR"));
|
||||
}
|
||||
if(_loc12_)
|
||||
{
|
||||
_loc5_.streamType = "live";
|
||||
}
|
||||
if(_loc5_.media.length > 1 && _loc6_)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("f4mBitrateMissing"));
|
||||
}
|
||||
for each(var _loc4_:XML in _loc9_.drmAdditionalHeader)
|
||||
{
|
||||
parseDRMAdditionalHeader(_loc4_,_loc5_.media,_loc8_,_loc5_);
|
||||
}
|
||||
for each(var _loc13_:XML in _loc9_.bootstrapInfo)
|
||||
{
|
||||
parseBootstrapInfo(_loc13_,_loc5_.media,_loc8_,_loc5_);
|
||||
}
|
||||
generateRTMPBaseURL(_loc5_);
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function parseMedia(param1:XML, param2:String) : Media
|
||||
{
|
||||
var _loc6_:Base64Decoder = null;
|
||||
var _loc4_:ByteArray = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc7_:Media = new Media();
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc7_.url = param1.@url;
|
||||
if(param1.attribute("bitrate").length() > 0)
|
||||
{
|
||||
_loc7_.bitrate = param1.@bitrate;
|
||||
}
|
||||
if(param1.attribute("drmAdditionalHeaderId").length() > 0)
|
||||
{
|
||||
_loc7_.drmAdditionalHeader.id = param1.@drmAdditionalHeaderId;
|
||||
}
|
||||
if(param1.attribute("bootstrapInfoId").length() > 0)
|
||||
{
|
||||
_loc7_.bootstrapInfo = new BootstrapInfo();
|
||||
_loc7_.bootstrapInfo.id = param1.@bootstrapInfoId;
|
||||
}
|
||||
if(param1.attribute("height").length() > 0)
|
||||
{
|
||||
_loc7_.height = param1.@height;
|
||||
}
|
||||
if(param1.attribute("width").length() > 0)
|
||||
{
|
||||
_loc7_.width = param1.@width;
|
||||
}
|
||||
if(param1.attribute("groupspec").length() > 0)
|
||||
{
|
||||
_loc7_.multicastGroupspec = param1.@groupspec;
|
||||
}
|
||||
if(param1.attribute("multicastStreamName").length() > 0)
|
||||
{
|
||||
_loc7_.multicastStreamName = param1.@multicastStreamName;
|
||||
}
|
||||
if(param1.moov.length() > 0)
|
||||
{
|
||||
_loc6_ = new Base64Decoder();
|
||||
_loc6_.decode(param1.moov.text());
|
||||
_loc7_.moov = _loc6_.drain();
|
||||
}
|
||||
if(param1.metadata.length() > 0)
|
||||
{
|
||||
_loc6_ = new Base64Decoder();
|
||||
_loc6_.decode(param1.metadata.text());
|
||||
_loc4_ = _loc6_.drain();
|
||||
_loc4_.position = 0;
|
||||
_loc4_.objectEncoding = 0;
|
||||
try
|
||||
{
|
||||
_loc5_ = _loc4_.readObject() as String;
|
||||
_loc3_ = _loc4_.readObject();
|
||||
_loc7_.metadata = _loc3_;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
if(param1.xmpMetadata.length() > 0)
|
||||
{
|
||||
_loc6_ = new Base64Decoder();
|
||||
_loc6_.decode(param1.xmpMetadata.text());
|
||||
_loc7_.xmp = _loc6_.drain();
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString("f4mMediaURLMissing"));
|
||||
}
|
||||
|
||||
private function parseDVRInfo(param1:XML, param2:String, param3:Manifest) : void
|
||||
{
|
||||
var _loc7_:String = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:String = null;
|
||||
var _loc6_:DVRInfo = new DVRInfo();
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc6_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc7_ = param1.@url;
|
||||
if(!isAbsoluteURL(_loc7_))
|
||||
{
|
||||
_loc7_ = param2 + "/" + _loc7_;
|
||||
}
|
||||
_loc6_.url = _loc7_;
|
||||
}
|
||||
if(param1.attribute("beginOffset").length() > 0)
|
||||
{
|
||||
_loc6_.beginOffset = Math.max(0,parseInt(param1.@beginOffset));
|
||||
}
|
||||
if(param1.attribute("endOffset").length() > 0)
|
||||
{
|
||||
_loc5_ = new Number(param1.@endOffset);
|
||||
if(_loc5_ > 0 && _loc5_ < 1)
|
||||
{
|
||||
_loc6_.endOffset = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.endOffset = Math.max(0,_loc5_);
|
||||
}
|
||||
}
|
||||
if(param1.attribute("offline").length() > 0)
|
||||
{
|
||||
_loc4_ = param1.@offline;
|
||||
_loc6_.offline = _loc4_.toLowerCase() == "true";
|
||||
}
|
||||
param3.dvrInfo = _loc6_;
|
||||
}
|
||||
|
||||
private function parseDRMAdditionalHeader(param1:XML, param2:Vector.<Media>, param3:String, param4:Manifest) : void
|
||||
{
|
||||
var _loc7_:* = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc8_:Base64Decoder = null;
|
||||
var _loc9_:String = null;
|
||||
var _loc6_:DRMAdditionalHeader = new DRMAdditionalHeader();
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc6_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc9_ = param1.@url;
|
||||
if(!isAbsoluteURL(_loc9_))
|
||||
{
|
||||
_loc9_ = param3 + "/" + _loc9_;
|
||||
}
|
||||
_loc6_.url = _loc9_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = param1.text();
|
||||
_loc8_ = new Base64Decoder();
|
||||
_loc8_.decode(_loc5_);
|
||||
_loc6_.data = _loc8_.drain();
|
||||
}
|
||||
param4.drmAdditionalHeaders.push(_loc6_);
|
||||
for each(_loc7_ in param2)
|
||||
{
|
||||
if(_loc7_.drmAdditionalHeader.id == _loc6_.id)
|
||||
{
|
||||
_loc7_.drmAdditionalHeader = _loc6_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function parseBootstrapInfo(param1:XML, param2:Vector.<Media>, param3:String, param4:Manifest) : void
|
||||
{
|
||||
var _loc7_:* = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc8_:Base64Decoder = null;
|
||||
var _loc9_:String = null;
|
||||
var _loc6_:BootstrapInfo = new BootstrapInfo();
|
||||
if(param1.attribute("profile").length() > 0)
|
||||
{
|
||||
_loc6_.profile = param1.@profile;
|
||||
if(param1.attribute("id").length() > 0)
|
||||
{
|
||||
_loc6_.id = param1.@id;
|
||||
}
|
||||
if(param1.attribute("url").length() > 0)
|
||||
{
|
||||
_loc9_ = param1.@url;
|
||||
if(!isAbsoluteURL(_loc9_) && param3 != null)
|
||||
{
|
||||
_loc9_ = param3 + "/" + _loc9_;
|
||||
}
|
||||
_loc6_.url = _loc9_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = param1.text();
|
||||
_loc8_ = new Base64Decoder();
|
||||
_loc8_.decode(_loc5_);
|
||||
_loc6_.data = _loc8_.drain();
|
||||
}
|
||||
for each(_loc7_ in param2)
|
||||
{
|
||||
if(_loc7_.bootstrapInfo == null)
|
||||
{
|
||||
_loc7_.bootstrapInfo = _loc6_;
|
||||
}
|
||||
else if(_loc7_.bootstrapInfo.id == _loc6_.id)
|
||||
{
|
||||
_loc7_.bootstrapInfo = _loc6_;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString("f4mProfileMissing"));
|
||||
}
|
||||
|
||||
private function generateRTMPBaseURL(param1:Manifest) : void
|
||||
{
|
||||
if(param1.baseURL == null)
|
||||
{
|
||||
for each(var _loc2_:Media in param1.media)
|
||||
{
|
||||
if(NetStreamUtils.isRTMPStream(_loc2_.url))
|
||||
{
|
||||
param1.baseURL = _loc2_.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createResource(param1:Manifest, param2:URLResource) : MediaResourceBase
|
||||
{
|
||||
var _loc6_:StreamingURLResource = null;
|
||||
var _loc8_:Media = null;
|
||||
var _loc11_:* = undefined;
|
||||
var _loc10_:String = null;
|
||||
var _loc19_:String = null;
|
||||
var _loc13_:String = null;
|
||||
var _loc12_:String = null;
|
||||
var _loc18_:DynamicStreamingResource = null;
|
||||
var _loc9_:* = undefined;
|
||||
var _loc14_:String = null;
|
||||
var _loc4_:DynamicStreamingItem = null;
|
||||
var _loc16_:Metadata = null;
|
||||
var _loc17_:Metadata = null;
|
||||
var _loc15_:URL = new URL(param2.url);
|
||||
var _loc3_:String = "/" + _loc15_.path;
|
||||
_loc3_ = _loc3_.substr(0,_loc3_.lastIndexOf("/"));
|
||||
var _loc7_:String = _loc15_.protocol + "://" + _loc15_.host + (_loc15_.port != "" ? ":" + _loc15_.port : "") + _loc3_;
|
||||
if(param1.media.length == 1)
|
||||
{
|
||||
_loc8_ = param1.media[0] as Media;
|
||||
_loc10_ = _loc8_.url;
|
||||
_loc13_ = null;
|
||||
if(isAbsoluteURL(_loc10_))
|
||||
{
|
||||
_loc13_ = _loc8_.url.substr(0,_loc8_.url.lastIndexOf("/"));
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc13_ = param1.baseURL;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = _loc7_;
|
||||
}
|
||||
if(_loc8_.multicastGroupspec != null && _loc8_.multicastGroupspec.length > 0 && _loc8_.multicastStreamName != null && _loc8_.multicastStreamName.length > 0)
|
||||
{
|
||||
if(isAbsoluteURL(_loc10_))
|
||||
{
|
||||
_loc6_ = new MulticastResource(_loc10_,param1.streamType);
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc6_ = new MulticastResource(param1.baseURL + "/" + _loc10_,streamType(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new MulticastResource(_loc7_ + "/" + _loc10_,streamType(param1));
|
||||
}
|
||||
MulticastResource(_loc6_).groupspec = _loc8_.multicastGroupspec;
|
||||
MulticastResource(_loc6_).streamName = _loc8_.multicastStreamName;
|
||||
}
|
||||
else if(isAbsoluteURL(_loc10_))
|
||||
{
|
||||
_loc6_ = new StreamingURLResource(_loc10_,param1.streamType);
|
||||
}
|
||||
else if(param1.baseURL != null)
|
||||
{
|
||||
_loc6_ = new StreamingURLResource(param1.baseURL + "/" + _loc10_,streamType(param1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new StreamingURLResource(_loc7_ + "/" + _loc10_,streamType(param1));
|
||||
}
|
||||
_loc6_.urlIncludesFMSApplicationInstance = param1.urlIncludesFMSApplicationInstance;
|
||||
if(_loc8_.bootstrapInfo != null)
|
||||
{
|
||||
_loc11_ = new Vector.<String>();
|
||||
_loc11_.push(_loc13_);
|
||||
_loc19_ = _loc8_.bootstrapInfo.url;
|
||||
if(_loc8_.bootstrapInfo.url != null && isAbsoluteURL(_loc8_.bootstrapInfo.url) == false)
|
||||
{
|
||||
_loc19_ = _loc7_ + "/" + _loc19_;
|
||||
_loc8_.bootstrapInfo.url = _loc19_;
|
||||
}
|
||||
_loc17_ = new Metadata();
|
||||
_loc17_.addValue("bootstrap",_loc8_.bootstrapInfo);
|
||||
if(_loc11_.length > 0)
|
||||
{
|
||||
_loc17_.addValue("serverBaseUrls",_loc11_);
|
||||
}
|
||||
}
|
||||
if(_loc8_.metadata != null)
|
||||
{
|
||||
if(_loc17_ == null)
|
||||
{
|
||||
_loc17_ = new Metadata();
|
||||
}
|
||||
_loc17_.addValue("streamMetadata",_loc8_.metadata);
|
||||
}
|
||||
if(_loc8_.xmp != null)
|
||||
{
|
||||
if(_loc17_ == null)
|
||||
{
|
||||
_loc17_ = new Metadata();
|
||||
}
|
||||
_loc17_.addValue("xmpMetadata",_loc8_.xmp);
|
||||
}
|
||||
if(_loc8_.drmAdditionalHeader != null)
|
||||
{
|
||||
_loc16_ = new Metadata();
|
||||
if(Media(param1.media[0]).drmAdditionalHeader != null && Media(param1.media[0]).drmAdditionalHeader.data != null)
|
||||
{
|
||||
_loc16_.addValue("DRMAdditionalHeader",Media(param1.media[0]).drmAdditionalHeader.data);
|
||||
_loc6_.drmContentData = extractDRMMetadata(Media(param1.media[0]).drmAdditionalHeader.data);
|
||||
}
|
||||
}
|
||||
if(_loc17_ != null)
|
||||
{
|
||||
_loc6_.addMetadataValue("http://www.osmf.org/httpstreaming/1.0",_loc17_);
|
||||
}
|
||||
if(_loc16_ != null)
|
||||
{
|
||||
_loc6_.addMetadataValue("http://www.osmf.org/drm/1.0",_loc16_);
|
||||
}
|
||||
}
|
||||
else if(param1.media.length > 1)
|
||||
{
|
||||
_loc12_ = param1.baseURL != null ? param1.baseURL : _loc7_;
|
||||
_loc11_ = new Vector.<String>();
|
||||
_loc11_.push(_loc12_);
|
||||
_loc18_ = new DynamicStreamingResource(_loc12_,streamType(param1));
|
||||
_loc18_.urlIncludesFMSApplicationInstance = param1.urlIncludesFMSApplicationInstance;
|
||||
_loc9_ = new Vector.<DynamicStreamingItem>();
|
||||
if(NetStreamUtils.isRTMPStream(_loc12_) == false)
|
||||
{
|
||||
_loc17_ = new Metadata();
|
||||
_loc18_.addMetadataValue("http://www.osmf.org/httpstreaming/1.0",_loc17_);
|
||||
_loc17_.addValue("serverBaseUrls",_loc11_);
|
||||
}
|
||||
for each(_loc8_ in param1.media)
|
||||
{
|
||||
if(isAbsoluteURL(_loc8_.url))
|
||||
{
|
||||
_loc14_ = NetStreamUtils.getStreamNameFromURL(_loc8_.url);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc14_ = _loc8_.url;
|
||||
}
|
||||
_loc4_ = new DynamicStreamingItem(_loc14_,_loc8_.bitrate,_loc8_.width,_loc8_.height);
|
||||
_loc9_.push(_loc4_);
|
||||
if(_loc8_.drmAdditionalHeader != null)
|
||||
{
|
||||
if(_loc18_.getMetadataValue("http://www.osmf.org/drm/1.0") == null)
|
||||
{
|
||||
_loc16_ = new Metadata();
|
||||
_loc18_.addMetadataValue("http://www.osmf.org/drm/1.0",_loc16_);
|
||||
}
|
||||
if(_loc8_.drmAdditionalHeader != null && _loc8_.drmAdditionalHeader.data != null)
|
||||
{
|
||||
_loc16_.addValue(_loc4_.streamName,extractDRMMetadata(_loc8_.drmAdditionalHeader.data));
|
||||
_loc16_.addValue("DRMAdditionalHeader" + _loc4_.streamName,_loc8_.drmAdditionalHeader.data);
|
||||
}
|
||||
}
|
||||
if(_loc8_.bootstrapInfo != null)
|
||||
{
|
||||
_loc19_ = _loc8_.bootstrapInfo.url ? _loc8_.bootstrapInfo.url : null;
|
||||
if(_loc8_.bootstrapInfo.url != null && isAbsoluteURL(_loc8_.bootstrapInfo.url) == false)
|
||||
{
|
||||
_loc19_ = _loc7_ + "/" + _loc19_;
|
||||
_loc8_.bootstrapInfo.url = _loc19_;
|
||||
}
|
||||
_loc17_.addValue("bootstrap" + _loc4_.streamName,_loc8_.bootstrapInfo);
|
||||
}
|
||||
if(_loc8_.metadata != null)
|
||||
{
|
||||
_loc17_.addValue("streamMetadata" + _loc4_.streamName,_loc8_.metadata);
|
||||
}
|
||||
if(_loc8_.xmp != null)
|
||||
{
|
||||
_loc17_.addValue("xmpMetadata" + _loc4_.streamName,_loc8_.xmp);
|
||||
}
|
||||
}
|
||||
_loc18_.streamItems = _loc9_;
|
||||
_loc6_ = _loc18_;
|
||||
}
|
||||
else if(param1.baseURL == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("f4mMediaURLMissing"));
|
||||
}
|
||||
if(param1.mimeType != null)
|
||||
{
|
||||
_loc6_.mediaType = "video";
|
||||
_loc6_.mimeType = param1.mimeType;
|
||||
}
|
||||
var _loc5_:StreamingURLResource = param2 as StreamingURLResource;
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc6_.clipStartTime = _loc5_.clipStartTime;
|
||||
_loc6_.clipEndTime = _loc5_.clipEndTime;
|
||||
}
|
||||
_loc6_.addMetadataValue("http://www.osmf.org/derivedResource/1.0",param2);
|
||||
addDVRInfo(param1,_loc6_);
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function isAbsoluteURL(param1:String) : Boolean
|
||||
{
|
||||
var _loc2_:URL = new URL(param1);
|
||||
return _loc2_.absolute;
|
||||
}
|
||||
|
||||
private function extractDRMMetadata(param1:ByteArray) : ByteArray
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc6_:Object = null;
|
||||
var _loc9_:Object = null;
|
||||
var _loc10_:Object = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc8_:Base64Decoder = null;
|
||||
var _loc2_:ByteArray = null;
|
||||
param1.position = 0;
|
||||
param1.objectEncoding = 0;
|
||||
try
|
||||
{
|
||||
_loc4_ = param1.readObject();
|
||||
_loc3_ = param1.readObject();
|
||||
_loc6_ = _loc3_["Encryption"];
|
||||
_loc9_ = _loc6_["Params"];
|
||||
_loc10_ = _loc9_["KeyInfo"];
|
||||
_loc5_ = _loc10_["FMRMS_METADATA"];
|
||||
_loc7_ = _loc5_["Metadata"] as String;
|
||||
_loc8_ = new Base64Decoder();
|
||||
_loc8_.decode(_loc7_);
|
||||
_loc2_ = _loc8_.drain();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_loc2_ = null;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function addDVRInfo(param1:Manifest, param2:StreamingURLResource) : void
|
||||
{
|
||||
if(param1.dvrInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:Metadata = new Metadata();
|
||||
_loc3_.addValue("beginOffset",param1.dvrInfo.beginOffset);
|
||||
_loc3_.addValue("endOffset",param1.dvrInfo.endOffset);
|
||||
_loc3_.addValue("dvrOffline",param1.dvrInfo.offline);
|
||||
_loc3_.addValue("dvrId",param1.dvrInfo.id);
|
||||
param2.addMetadataValue("http://www.osmf.org/dvr/1.0",_loc3_);
|
||||
}
|
||||
|
||||
private function streamType(param1:Manifest) : String
|
||||
{
|
||||
return param1.streamType == "live" && param1.dvrInfo != null ? "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,54 @@
|
||||
package org.osmf.elements.loaderClasses
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.events.ProgressEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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 _loader;
|
||||
}
|
||||
|
||||
public function set loader(param1:Loader) : void
|
||||
{
|
||||
_loader = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "loading")
|
||||
{
|
||||
loader.contentLoaderInfo.addEventListener("progress",onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == "ready")
|
||||
{
|
||||
setBytesTotal(loader.contentLoaderInfo.bytesTotal);
|
||||
setBytesLoaded(loader.contentLoaderInfo.bytesLoaded);
|
||||
loader.contentLoaderInfo.addEventListener("progress",onContentLoadProgress,false,0,true);
|
||||
}
|
||||
else if(param1 == "uninitialized")
|
||||
{
|
||||
setBytesLoaded(0);
|
||||
}
|
||||
}
|
||||
|
||||
private function onContentLoadProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
setBytesTotal(param1.bytesTotal);
|
||||
setBytesLoaded(param1.bytesLoaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
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.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.URLResource;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
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 _loc5_:Number = 0;
|
||||
var _loc4_:Number = 0;
|
||||
var _loc6_:LoaderInfo = param1.contentLoaderInfo;
|
||||
_loc3_ = param1;
|
||||
_loc3_.scrollRect = new Rectangle(0,0,_loc6_.width,_loc6_.height);
|
||||
_loc5_ = _loc6_.width;
|
||||
_loc4_ = _loc6_.height;
|
||||
return new DisplayObjectTrait(_loc3_,_loc5_,_loc4_);
|
||||
}
|
||||
|
||||
public static function loadLoadTrait(param1:LoadTrait, param2:Function, param3:Boolean, param4:Boolean, param5:Function = null) : void
|
||||
{
|
||||
var context:LoaderContext;
|
||||
var urlReq:URLRequest;
|
||||
var loadTrait:LoadTrait = param1;
|
||||
var updateLoadTraitFunction:Function = param2;
|
||||
var useCurrentSecurityDomain:Boolean = param3;
|
||||
var checkPolicyFile:Boolean = param4;
|
||||
var validateLoadedContentFunction:Function = param5;
|
||||
var toggleLoaderListeners:* = function(param1:Loader, param2:Boolean):void
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
param1.contentLoaderInfo.addEventListener("complete",onLoadComplete);
|
||||
param1.contentLoaderInfo.addEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.addEventListener("securityError",onSecurityError);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.contentLoaderInfo.removeEventListener("complete",onLoadComplete);
|
||||
param1.contentLoaderInfo.removeEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.removeEventListener("securityError",onSecurityError);
|
||||
}
|
||||
};
|
||||
var onLoadComplete:* = function(param1:Event):void
|
||||
{
|
||||
var validated:Boolean;
|
||||
var timer:Timer;
|
||||
var onTimer:*;
|
||||
var event:Event = param1;
|
||||
toggleLoaderListeners(loader,false);
|
||||
if(loadTrait.loadState == "loading")
|
||||
{
|
||||
if(validateLoadedContentFunction != null)
|
||||
{
|
||||
validated = Boolean(validateLoadedContentFunction(loader.content));
|
||||
if(validated)
|
||||
{
|
||||
if(Capabilities.isDebugger)
|
||||
{
|
||||
onTimer = function(param1:TimerEvent):void
|
||||
{
|
||||
timer.removeEventListener("timerComplete",onTimer);
|
||||
timer = null;
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
};
|
||||
timer = new Timer(250,1);
|
||||
timer.addEventListener("timerComplete",onTimer);
|
||||
timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
loadLoadTrait(loadTrait,updateLoadTraitFunction,useCurrentSecurityDomain,false,null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.unloadAndStop();
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateLoadTraitFunction(loadTrait,"ready");
|
||||
}
|
||||
}
|
||||
};
|
||||
var onIOError:* = function(param1:IOErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1,param1 ? param1.text : param2)));
|
||||
};
|
||||
var onSecurityError:* = function(param1:SecurityErrorEvent, param2:String = null):void
|
||||
{
|
||||
toggleLoaderListeners(loader,false);
|
||||
loader = null;
|
||||
updateLoadTraitFunction(loadTrait,"loadError");
|
||||
loadTrait.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(2,param1 ? param1.text : param2)));
|
||||
};
|
||||
var loaderLoadTrait:LoaderLoadTrait = loadTrait as LoaderLoadTrait;
|
||||
var loader:Loader = new Loader();
|
||||
loaderLoadTrait.loader = loader;
|
||||
updateLoadTraitFunction(loadTrait,"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,"unloading");
|
||||
_loc3_.loader.unloadAndStop();
|
||||
param2(param1,"uninitialized");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("loadStateChange",false,false,loadState));
|
||||
}
|
||||
|
||||
public function set mediaElement(param1:MediaElement) : void
|
||||
{
|
||||
_mediaElement = param1;
|
||||
}
|
||||
|
||||
public function get mediaElement() : MediaElement
|
||||
{
|
||||
return _mediaElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.osmf.elements.proxyClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.metadata.Metadata;
|
||||
|
||||
public class ProxyMetadata extends Metadata
|
||||
{
|
||||
|
||||
private var proxiedMetadata:Metadata;
|
||||
|
||||
public function ProxyMetadata()
|
||||
{
|
||||
super();
|
||||
proxiedMetadata = new Metadata();
|
||||
proxiedMetadata.addEventListener("valueAdd",redispatchEvent);
|
||||
proxiedMetadata.addEventListener("valueChange",redispatchEvent);
|
||||
proxiedMetadata.addEventListener("valueRemove",redispatchEvent);
|
||||
}
|
||||
|
||||
public function set metadata(param1:Metadata) : void
|
||||
{
|
||||
proxiedMetadata.removeEventListener("valueAdd",redispatchEvent);
|
||||
proxiedMetadata.removeEventListener("valueChange",redispatchEvent);
|
||||
proxiedMetadata.removeEventListener("valueRemove",redispatchEvent);
|
||||
for each(var _loc2_:String in proxiedMetadata.keys)
|
||||
{
|
||||
param1.addValue(_loc2_,proxiedMetadata.getValue(_loc2_));
|
||||
}
|
||||
proxiedMetadata = param1;
|
||||
proxiedMetadata.addEventListener("valueAdd",redispatchEvent);
|
||||
proxiedMetadata.addEventListener("valueChange",redispatchEvent);
|
||||
proxiedMetadata.addEventListener("valueRemove",redispatchEvent);
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
return proxiedMetadata.getValue(param1);
|
||||
}
|
||||
|
||||
override public function addValue(param1:String, param2:Object) : void
|
||||
{
|
||||
proxiedMetadata.addValue(param1,param2);
|
||||
}
|
||||
|
||||
override public function removeValue(param1:String) : *
|
||||
{
|
||||
return proxiedMetadata.removeValue(param1);
|
||||
}
|
||||
|
||||
override public function get keys() : Vector.<String>
|
||||
{
|
||||
return proxiedMetadata.keys;
|
||||
}
|
||||
|
||||
private function redispatchEvent(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class AudioEvent extends Event
|
||||
{
|
||||
|
||||
public static const VOLUME_CHANGE:String = "volumeChange";
|
||||
|
||||
public static const MUTED_CHANGE:String = "mutedChange";
|
||||
|
||||
public static const PAN_CHANGE:String = "panChange";
|
||||
|
||||
private var _muted:Boolean;
|
||||
|
||||
private var _volume:Number;
|
||||
|
||||
private var _pan:Number;
|
||||
|
||||
public function AudioEvent(param1:String, param2:Boolean, param3:Boolean, param4:Boolean = false, param5:Number = NaN, param6:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_muted = param4;
|
||||
_volume = param5;
|
||||
_pan = param6;
|
||||
}
|
||||
|
||||
public function get muted() : Boolean
|
||||
{
|
||||
return _muted;
|
||||
}
|
||||
|
||||
public function get volume() : Number
|
||||
{
|
||||
return _volume;
|
||||
}
|
||||
|
||||
public function get pan() : Number
|
||||
{
|
||||
return _pan;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new AudioEvent(type,bubbles,cancelable,_muted,_volume,_pan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class BufferEvent extends Event
|
||||
{
|
||||
|
||||
public static const BUFFERING_CHANGE:String = "bufferingChange";
|
||||
|
||||
public static const BUFFER_TIME_CHANGE:String = "bufferTimeChange";
|
||||
|
||||
public static const BUFFER_LENGTH_CHANGE:String = "bufferLengthChange";
|
||||
|
||||
private var _buffering:Boolean;
|
||||
|
||||
private var _bufferTime:Number;
|
||||
|
||||
private var _bufferLength:Number;
|
||||
|
||||
public function BufferEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Boolean = false, param5:Number = NaN, param6:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_buffering = param4;
|
||||
_bufferTime = param5;
|
||||
_bufferLength = param6;
|
||||
}
|
||||
|
||||
public function get buffering() : Boolean
|
||||
{
|
||||
return _buffering;
|
||||
}
|
||||
|
||||
public function get bufferTime() : Number
|
||||
{
|
||||
return _bufferTime;
|
||||
}
|
||||
|
||||
public function get bufferLength() : Number
|
||||
{
|
||||
return _bufferLength;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new BufferEvent(type,bubbles,cancelable,_buffering,_bufferTime,_bufferLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.containers.IMediaContainer;
|
||||
|
||||
public class ContainerChangeEvent extends Event
|
||||
{
|
||||
|
||||
public static const CONTAINER_CHANGE:String = "containerChange";
|
||||
|
||||
private var _oldContainer:IMediaContainer;
|
||||
|
||||
private var _newContainer:IMediaContainer;
|
||||
|
||||
public function ContainerChangeEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:IMediaContainer = null, param5:IMediaContainer = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_oldContainer = param4;
|
||||
_newContainer = param5;
|
||||
}
|
||||
|
||||
public function get oldContainer() : IMediaContainer
|
||||
{
|
||||
return _oldContainer;
|
||||
}
|
||||
|
||||
public function get newContainer() : IMediaContainer
|
||||
{
|
||||
return _newContainer;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new ContainerChangeEvent(type,bubbles,cancelable,_oldContainer,_newContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class DRMEvent extends Event
|
||||
{
|
||||
|
||||
public static const DRM_STATE_CHANGE:String = "drmStateChange";
|
||||
|
||||
private var _drmState:String;
|
||||
|
||||
private var _startDate:Date;
|
||||
|
||||
private var _endDate:Date;
|
||||
|
||||
private var _period:Number;
|
||||
|
||||
private var _serverURL:String;
|
||||
|
||||
private var _token:Object;
|
||||
|
||||
private var _mediaError:MediaError;
|
||||
|
||||
public function DRMEvent(param1:String, param2:String, param3:Boolean = false, param4:Boolean = false, param5:Date = null, param6:Date = null, param7:Number = 0, param8:String = null, param9:Object = null, param10:MediaError = null)
|
||||
{
|
||||
super(param1,param3,param4);
|
||||
_drmState = param2;
|
||||
_token = param9;
|
||||
_mediaError = param10;
|
||||
_startDate = param5;
|
||||
_endDate = param6;
|
||||
_period = param7;
|
||||
_serverURL = param8;
|
||||
}
|
||||
|
||||
public function get token() : Object
|
||||
{
|
||||
return _token;
|
||||
}
|
||||
|
||||
public function get mediaError() : MediaError
|
||||
{
|
||||
return _mediaError;
|
||||
}
|
||||
|
||||
public function get startDate() : Date
|
||||
{
|
||||
return _startDate;
|
||||
}
|
||||
|
||||
public function get endDate() : Date
|
||||
{
|
||||
return _endDate;
|
||||
}
|
||||
|
||||
public function get period() : Number
|
||||
{
|
||||
return _period;
|
||||
}
|
||||
|
||||
public function get drmState() : String
|
||||
{
|
||||
return _drmState;
|
||||
}
|
||||
|
||||
public function get serverURL() : String
|
||||
{
|
||||
return _serverURL;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DRMEvent(type,_drmState,bubbles,cancelable,_startDate,_endDate,_period,_serverURL,_token,_mediaError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class DVREvent extends Event
|
||||
{
|
||||
|
||||
public static const IS_RECORDING_CHANGE:String = "isRecordingChange";
|
||||
|
||||
public function DVREvent(param1:String, param2:Boolean = false, param3:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DVREvent(type,bubbles,cancelable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class DVRStreamInfoEvent extends Event
|
||||
{
|
||||
|
||||
public static const DVRSTREAMINFO:String = "DVRStreamInfo";
|
||||
|
||||
private var _info:Object;
|
||||
|
||||
public function DVRStreamInfoEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Object = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_info = param4;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DVRStreamInfoEvent(type,bubbles,cancelable,info);
|
||||
}
|
||||
|
||||
public function get info() : Object
|
||||
{
|
||||
return _info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
|
||||
public class DisplayObjectEvent extends Event
|
||||
{
|
||||
|
||||
public static const DISPLAY_OBJECT_CHANGE:String = "displayObjectChange";
|
||||
|
||||
public static const MEDIA_SIZE_CHANGE:String = "mediaSizeChange";
|
||||
|
||||
private var _oldDisplayObject:DisplayObject;
|
||||
|
||||
private var _newDisplayObject:DisplayObject;
|
||||
|
||||
private var _oldWidth:Number;
|
||||
|
||||
private var _oldHeight:Number;
|
||||
|
||||
private var _newWidth:Number;
|
||||
|
||||
private var _newHeight:Number;
|
||||
|
||||
public function DisplayObjectEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:DisplayObject = null, param5:DisplayObject = null, param6:Number = NaN, param7:Number = NaN, param8:Number = NaN, param9:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_oldDisplayObject = param4;
|
||||
_newDisplayObject = param5;
|
||||
_oldWidth = param6;
|
||||
_oldHeight = param7;
|
||||
_newWidth = param8;
|
||||
_newHeight = param9;
|
||||
}
|
||||
|
||||
public function get oldDisplayObject() : DisplayObject
|
||||
{
|
||||
return _oldDisplayObject;
|
||||
}
|
||||
|
||||
public function get newDisplayObject() : DisplayObject
|
||||
{
|
||||
return _newDisplayObject;
|
||||
}
|
||||
|
||||
public function get oldWidth() : Number
|
||||
{
|
||||
return _oldWidth;
|
||||
}
|
||||
|
||||
public function get oldHeight() : Number
|
||||
{
|
||||
return _oldHeight;
|
||||
}
|
||||
|
||||
public function get newWidth() : Number
|
||||
{
|
||||
return _newWidth;
|
||||
}
|
||||
|
||||
public function get newHeight() : Number
|
||||
{
|
||||
return _newHeight;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DisplayObjectEvent(type,bubbles,cancelable,_oldDisplayObject,_newDisplayObject,_oldWidth,_oldHeight,_newWidth,_newHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class DynamicStreamEvent extends Event
|
||||
{
|
||||
|
||||
public static const SWITCHING_CHANGE:String = "switchingChange";
|
||||
|
||||
public static const NUM_DYNAMIC_STREAMS_CHANGE:String = "numDynamicStreamsChange";
|
||||
|
||||
public static const AUTO_SWITCH_CHANGE:String = "autoSwitchChange";
|
||||
|
||||
private var _switching:Boolean;
|
||||
|
||||
private var _autoSwitch:Boolean;
|
||||
|
||||
public function DynamicStreamEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Boolean = false, param5:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_switching = param4;
|
||||
_autoSwitch = param5;
|
||||
}
|
||||
|
||||
public function get switching() : Boolean
|
||||
{
|
||||
return _switching;
|
||||
}
|
||||
|
||||
public function get autoSwitch() : Boolean
|
||||
{
|
||||
return _autoSwitch;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new DynamicStreamEvent(type,bubbles,cancelable,_switching,_autoSwitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.net.httpstreaming.f4f.AdobeBootstrapBox;
|
||||
import org.osmf.net.httpstreaming.flv.FLVTagScriptDataObject;
|
||||
|
||||
public class HTTPStreamingFileHandlerEvent extends Event
|
||||
{
|
||||
|
||||
public static const NOTIFY_SEGMENT_DURATION:String = "notifySegmentDuration";
|
||||
|
||||
public static const NOTIFY_SCRIPT_DATA:String = "notifyScriptData";
|
||||
|
||||
public static const NOTIFY_BOOTSTRAP_BOX:String = "notifyBootstrapBox";
|
||||
|
||||
public static const NOTIFY_ERROR:String = "notifyError";
|
||||
|
||||
private var _segmentDuration:Number;
|
||||
|
||||
private var _scriptDataObject:FLVTagScriptDataObject;
|
||||
|
||||
private var _scriptDataFirst:Boolean;
|
||||
|
||||
private var _scriptDataImmediate:Boolean;
|
||||
|
||||
private var _abst:AdobeBootstrapBox;
|
||||
|
||||
private var _error:Boolean;
|
||||
|
||||
public function HTTPStreamingFileHandlerEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Number = 0, param5:FLVTagScriptDataObject = null, param6:Boolean = false, param7:Boolean = false, param8:AdobeBootstrapBox = null, param9:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_segmentDuration = param4;
|
||||
_scriptDataObject = param5;
|
||||
_scriptDataFirst = param6;
|
||||
_scriptDataImmediate = param7;
|
||||
_abst = param8;
|
||||
_error = param9;
|
||||
}
|
||||
|
||||
public function get segmentDuration() : Number
|
||||
{
|
||||
return _segmentDuration;
|
||||
}
|
||||
|
||||
public function get scriptDataObject() : FLVTagScriptDataObject
|
||||
{
|
||||
return _scriptDataObject;
|
||||
}
|
||||
|
||||
public function get scriptDataFirst() : Boolean
|
||||
{
|
||||
return _scriptDataFirst;
|
||||
}
|
||||
|
||||
public function get scriptDataImmediate() : Boolean
|
||||
{
|
||||
return _scriptDataImmediate;
|
||||
}
|
||||
|
||||
public function get bootstrapBox() : AdobeBootstrapBox
|
||||
{
|
||||
return _abst;
|
||||
}
|
||||
|
||||
public function get error() : Boolean
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new HTTPStreamingFileHandlerEvent(type,bubbles,cancelable,segmentDuration,scriptDataObject,scriptDataFirst,scriptDataImmediate,bootstrapBox,error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.net.URLRequest;
|
||||
import org.osmf.net.httpstreaming.flv.FLVTagScriptDataObject;
|
||||
|
||||
public class HTTPStreamingIndexHandlerEvent extends Event
|
||||
{
|
||||
|
||||
public static const NOTIFY_INDEX_READY:String = "notifyIndexReady";
|
||||
|
||||
public static const NOTIFY_RATES:String = "notifyRates";
|
||||
|
||||
public static const REQUEST_LOAD_INDEX:String = "requestLoadIndex";
|
||||
|
||||
public static const NOTIFY_ERROR:String = "notifyError";
|
||||
|
||||
public static const NOTIFY_SEGMENT_DURATION:String = "notifySegmentDuration";
|
||||
|
||||
public static const NOTIFY_SCRIPT_DATA:String = "notifyScriptData";
|
||||
|
||||
private var _streamNames:Array;
|
||||
|
||||
private var _rates:Array;
|
||||
|
||||
private var _request:URLRequest;
|
||||
|
||||
private var _requestContext:Object;
|
||||
|
||||
private var _binaryData:Boolean;
|
||||
|
||||
private var _segmentDuration:Number;
|
||||
|
||||
private var _scriptDataObject:FLVTagScriptDataObject;
|
||||
|
||||
private var _scriptDataFirst:Boolean;
|
||||
|
||||
private var _scriptDataImmediate:Boolean;
|
||||
|
||||
private var _live:Boolean;
|
||||
|
||||
private var _offset:Number;
|
||||
|
||||
public function HTTPStreamingIndexHandlerEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Boolean = false, param5:Number = NaN, param6:Array = null, param7:Array = null, param8:URLRequest = null, param9:Object = null, param10:Boolean = true, param11:Number = 0, param12:FLVTagScriptDataObject = null, param13:Boolean = false, param14:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_live = param4;
|
||||
_offset = param5;
|
||||
_streamNames = param6;
|
||||
_rates = param7;
|
||||
_request = param8;
|
||||
_requestContext = param9;
|
||||
_binaryData = param10;
|
||||
_segmentDuration = param11;
|
||||
_scriptDataObject = param12;
|
||||
_scriptDataFirst = param13;
|
||||
_scriptDataImmediate = param14;
|
||||
}
|
||||
|
||||
public function get live() : Boolean
|
||||
{
|
||||
return _live;
|
||||
}
|
||||
|
||||
public function get offset() : Number
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
public function get streamNames() : Array
|
||||
{
|
||||
return _streamNames;
|
||||
}
|
||||
|
||||
public function get rates() : Array
|
||||
{
|
||||
return _rates;
|
||||
}
|
||||
|
||||
public function get request() : URLRequest
|
||||
{
|
||||
return _request;
|
||||
}
|
||||
|
||||
public function get requestContext() : Object
|
||||
{
|
||||
return _requestContext;
|
||||
}
|
||||
|
||||
public function get binaryData() : Boolean
|
||||
{
|
||||
return _binaryData;
|
||||
}
|
||||
|
||||
public function get segmentDuration() : Number
|
||||
{
|
||||
return _segmentDuration;
|
||||
}
|
||||
|
||||
public function get scriptDataObject() : FLVTagScriptDataObject
|
||||
{
|
||||
return _scriptDataObject;
|
||||
}
|
||||
|
||||
public function get scriptDataFirst() : Boolean
|
||||
{
|
||||
return _scriptDataFirst;
|
||||
}
|
||||
|
||||
public function get scriptDataImmediate() : Boolean
|
||||
{
|
||||
return _scriptDataImmediate;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new HTTPStreamingIndexHandlerEvent(type,bubbles,cancelable,live,offset,streamNames,rates,request,requestContext,binaryData,segmentDuration,scriptDataObject,scriptDataFirst,scriptDataImmediate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class LoadEvent extends Event
|
||||
{
|
||||
|
||||
public static const LOAD_STATE_CHANGE:String = "loadStateChange";
|
||||
|
||||
public static const BYTES_LOADED_CHANGE:String = "bytesLoadedChange";
|
||||
|
||||
public static const BYTES_TOTAL_CHANGE:String = "bytesTotalChange";
|
||||
|
||||
private var _loadState:String;
|
||||
|
||||
private var _bytes:Number;
|
||||
|
||||
public function LoadEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:String = null, param5:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_loadState = param4;
|
||||
_bytes = param5;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new LoadEvent(type,bubbles,cancelable,loadState,bytes);
|
||||
}
|
||||
|
||||
public function get loadState() : String
|
||||
{
|
||||
return _loadState;
|
||||
}
|
||||
|
||||
public function get bytes() : Number
|
||||
{
|
||||
return _bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoaderEvent extends Event
|
||||
{
|
||||
|
||||
public static const LOAD_STATE_CHANGE:String = "loadStateChange";
|
||||
|
||||
private var _loader:LoaderBase;
|
||||
|
||||
private var _loadTrait:LoadTrait;
|
||||
|
||||
private var _oldState:String;
|
||||
|
||||
private var _newState:String;
|
||||
|
||||
public function LoaderEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:LoaderBase = null, param5:LoadTrait = null, param6:String = null, param7:String = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_loader = param4;
|
||||
_loadTrait = param5;
|
||||
_oldState = param6;
|
||||
_newState = param7;
|
||||
}
|
||||
|
||||
public function get loader() : LoaderBase
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
public function get loadTrait() : LoadTrait
|
||||
{
|
||||
return _loadTrait;
|
||||
}
|
||||
|
||||
public function get oldState() : String
|
||||
{
|
||||
return _oldState;
|
||||
}
|
||||
|
||||
public function get newState() : String
|
||||
{
|
||||
return _newState;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new LoaderEvent(type,bubbles,cancelable,loader,loadTrait,oldState,newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MediaElementChangeEvent extends Event
|
||||
{
|
||||
|
||||
public static const MEDIA_ELEMENT_CHANGE:String = "mediaElementChange";
|
||||
|
||||
public function MediaElementChangeEvent(param1:String, param2:Boolean = false, param3:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaElementChangeEvent(type,bubbles,cancelable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.metadata.Metadata;
|
||||
|
||||
public class MediaElementEvent extends Event
|
||||
{
|
||||
|
||||
public static const TRAIT_ADD:String = "traitAdd";
|
||||
|
||||
public static const TRAIT_REMOVE:String = "traitRemove";
|
||||
|
||||
public static const METADATA_ADD:String = "metadataAdd";
|
||||
|
||||
public static const METADATA_REMOVE:String = "metadataRemove";
|
||||
|
||||
private var _traitType:String;
|
||||
|
||||
private var _namespaceURL:String;
|
||||
|
||||
private var _metadata:Metadata;
|
||||
|
||||
public function MediaElementEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:String = null, param5:String = null, param6:Metadata = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_traitType = param4;
|
||||
_namespaceURL = param5;
|
||||
_metadata = param6;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaElementEvent(type,bubbles,cancelable,traitType,namespaceURL,metadata);
|
||||
}
|
||||
|
||||
public function get traitType() : String
|
||||
{
|
||||
return _traitType;
|
||||
}
|
||||
|
||||
public function get namespaceURL() : String
|
||||
{
|
||||
return _namespaceURL;
|
||||
}
|
||||
|
||||
public function get metadata() : Metadata
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
public class MediaError extends Error
|
||||
{
|
||||
|
||||
private var _detail:String;
|
||||
|
||||
public function MediaError(param1:int, param2:String = null)
|
||||
{
|
||||
super(getMessageForErrorID(param1),param1);
|
||||
_detail = param2;
|
||||
}
|
||||
|
||||
public function get detail() : String
|
||||
{
|
||||
return _detail;
|
||||
}
|
||||
|
||||
protected function getMessageForErrorID(param1:int) : String
|
||||
{
|
||||
return MediaErrorCodes.getMessageForErrorID(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public final class MediaErrorCodes
|
||||
{
|
||||
|
||||
public static const IO_ERROR:int = 1;
|
||||
|
||||
public static const SECURITY_ERROR:int = 2;
|
||||
|
||||
public static const ASYNC_ERROR:int = 3;
|
||||
|
||||
public static const ARGUMENT_ERROR:int = 4;
|
||||
|
||||
public static const URL_SCHEME_INVALID:int = 5;
|
||||
|
||||
public static const HTTP_GET_FAILED:int = 6;
|
||||
|
||||
public static const MEDIA_LOAD_FAILED:int = 7;
|
||||
|
||||
public static const PLUGIN_VERSION_INVALID:int = 8;
|
||||
|
||||
public static const PLUGIN_IMPLEMENTATION_INVALID:int = 9;
|
||||
|
||||
public static const SOUND_PLAY_FAILED:int = 10;
|
||||
|
||||
public static const NETCONNECTION_REJECTED:int = 11;
|
||||
|
||||
public static const NETCONNECTION_APPLICATION_INVALID:int = 12;
|
||||
|
||||
public static const NETCONNECTION_FAILED:int = 13;
|
||||
|
||||
public static const NETCONNECTION_TIMEOUT:int = 14;
|
||||
|
||||
public static const NETSTREAM_PLAY_FAILED:int = 15;
|
||||
|
||||
public static const NETSTREAM_STREAM_NOT_FOUND:int = 16;
|
||||
|
||||
public static const NETSTREAM_FILE_STRUCTURE_INVALID:int = 17;
|
||||
|
||||
public static const NETSTREAM_NO_SUPPORTED_TRACK_FOUND:int = 18;
|
||||
|
||||
public static const DRM_SYSTEM_UPDATE_ERROR:int = 19;
|
||||
|
||||
public static const DVRCAST_SUBSCRIBE_FAILED:int = 20;
|
||||
|
||||
public static const DVRCAST_CONTENT_OFFLINE:int = 21;
|
||||
|
||||
public static const DVRCAST_STREAM_INFO_RETRIEVAL_FAILED:int = 22;
|
||||
|
||||
public static const F4M_FILE_INVALID:int = 23;
|
||||
|
||||
private static const errorMap:Array = [{
|
||||
"errorID":1,
|
||||
"message":"ioError"
|
||||
},{
|
||||
"errorID":2,
|
||||
"message":"securityError"
|
||||
},{
|
||||
"errorID":3,
|
||||
"message":"asyncError"
|
||||
},{
|
||||
"errorID":4,
|
||||
"message":"argumentError"
|
||||
},{
|
||||
"errorID":5,
|
||||
"message":"urlSchemeInvalid"
|
||||
},{
|
||||
"errorID":6,
|
||||
"message":"httpGetFailed"
|
||||
},{
|
||||
"errorID":7,
|
||||
"message":"mediaLoadFailed"
|
||||
},{
|
||||
"errorID":8,
|
||||
"message":"pluginVersionInvalid"
|
||||
},{
|
||||
"errorID":9,
|
||||
"message":"pluginImplementationInvalid"
|
||||
},{
|
||||
"errorID":10,
|
||||
"message":"soundPlayFailed"
|
||||
},{
|
||||
"errorID":11,
|
||||
"message":"netConnectionRejected"
|
||||
},{
|
||||
"errorID":12,
|
||||
"message":"netConnectionApplicationInvalid"
|
||||
},{
|
||||
"errorID":13,
|
||||
"message":"netConnectionFailed"
|
||||
},{
|
||||
"errorID":14,
|
||||
"message":"netConnectionTimeout"
|
||||
},{
|
||||
"errorID":15,
|
||||
"message":"netStreamPlayFailed"
|
||||
},{
|
||||
"errorID":16,
|
||||
"message":"netStreamStreamNotFound"
|
||||
},{
|
||||
"errorID":17,
|
||||
"message":"netStreamFileStructureInvalid"
|
||||
},{
|
||||
"errorID":18,
|
||||
"message":"netStreamNoSupportedTrackFound"
|
||||
},{
|
||||
"errorID":19,
|
||||
"message":"drmSystemUpdateError"
|
||||
},{
|
||||
"errorID":20,
|
||||
"message":"dvrCastSubscribeFailed"
|
||||
},{
|
||||
"errorID":21,
|
||||
"message":"dvrCastContentOffline"
|
||||
},{
|
||||
"errorID":22,
|
||||
"message":"dvrCastStreamInfoRetrievalFailed"
|
||||
},{
|
||||
"errorID":23,
|
||||
"message":"f4MFileINVALID"
|
||||
}];
|
||||
|
||||
public function MediaErrorCodes()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
internal static function getMessageForErrorID(param1:int) : String
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:String = "";
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < errorMap.length)
|
||||
{
|
||||
if(errorMap[_loc2_].errorID == param1)
|
||||
{
|
||||
_loc3_ = OSMFStrings.getString(errorMap[_loc2_].message);
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MediaErrorEvent extends Event
|
||||
{
|
||||
|
||||
public static const MEDIA_ERROR:String = "mediaError";
|
||||
|
||||
private var _error:MediaError;
|
||||
|
||||
public function MediaErrorEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:MediaError = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_error = param4;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaErrorEvent(type,bubbles,cancelable,error);
|
||||
}
|
||||
|
||||
public function get error() : MediaError
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
|
||||
public class MediaFactoryEvent extends Event
|
||||
{
|
||||
|
||||
public static const PLUGIN_LOAD:String = "pluginLoad";
|
||||
|
||||
public static const PLUGIN_LOAD_ERROR:String = "pluginLoadError";
|
||||
|
||||
public static const MEDIA_ELEMENT_CREATE:String = "mediaElementCreate";
|
||||
|
||||
private var _resource:MediaResourceBase;
|
||||
|
||||
private var _mediaElement:MediaElement;
|
||||
|
||||
public function MediaFactoryEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:MediaResourceBase = null, param5:MediaElement = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_resource = param4;
|
||||
_mediaElement = param5;
|
||||
}
|
||||
|
||||
public function get resource() : MediaResourceBase
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public function get mediaElement() : MediaElement
|
||||
{
|
||||
return _mediaElement;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaFactoryEvent(type,bubbles,cancelable,_resource,_mediaElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MediaPlayerCapabilityChangeEvent extends Event
|
||||
{
|
||||
|
||||
public static const CAN_PLAY_CHANGE:String = "canPlayChange";
|
||||
|
||||
public static const CAN_SEEK_CHANGE:String = "canSeekChange";
|
||||
|
||||
public static const TEMPORAL_CHANGE:String = "temporalChange";
|
||||
|
||||
public static const HAS_AUDIO_CHANGE:String = "hasAudioChange";
|
||||
|
||||
public static const IS_DYNAMIC_STREAM_CHANGE:String = "isDynamicStreamChange";
|
||||
|
||||
public static const CAN_LOAD_CHANGE:String = "canLoadChange";
|
||||
|
||||
public static const CAN_BUFFER_CHANGE:String = "canBufferChange";
|
||||
|
||||
public static const HAS_DRM_CHANGE:String = "hasDRMChange";
|
||||
|
||||
public static const HAS_DISPLAY_OBJECT_CHANGE:String = "hasDisplayObjectChange";
|
||||
|
||||
private var _enabled:Boolean;
|
||||
|
||||
public function MediaPlayerCapabilityChangeEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_enabled = param4;
|
||||
}
|
||||
|
||||
public function get enabled() : Boolean
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaPlayerCapabilityChangeEvent(type,bubbles,cancelable,_enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MediaPlayerStateChangeEvent extends Event
|
||||
{
|
||||
|
||||
public static const MEDIA_PLAYER_STATE_CHANGE:String = "mediaPlayerStateChange";
|
||||
|
||||
private var _state:String;
|
||||
|
||||
public function MediaPlayerStateChangeEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:String = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_state = param4;
|
||||
}
|
||||
|
||||
public function get state() : String
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MediaPlayerStateChangeEvent(type,bubbles,cancelable,_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class MetadataEvent extends Event
|
||||
{
|
||||
|
||||
public static const VALUE_ADD:String = "valueAdd";
|
||||
|
||||
public static const VALUE_REMOVE:String = "valueRemove";
|
||||
|
||||
public static const VALUE_CHANGE:String = "valueChange";
|
||||
|
||||
private var _key:String;
|
||||
|
||||
private var _value:*;
|
||||
|
||||
private var _oldValue:*;
|
||||
|
||||
public function MetadataEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:String = null, param5:* = null, param6:* = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_key = param4;
|
||||
_value = param5;
|
||||
_oldValue = param6;
|
||||
}
|
||||
|
||||
public function get key() : String
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
public function get value() : *
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public function get oldValue() : *
|
||||
{
|
||||
return _oldValue;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new MetadataEvent(type,bubbles,cancelable,_key,_value,_oldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.net.NetConnection;
|
||||
import org.osmf.media.URLResource;
|
||||
|
||||
public class NetConnectionFactoryEvent extends Event
|
||||
{
|
||||
|
||||
public static const CREATION_COMPLETE:String = "creationComplete";
|
||||
|
||||
public static const CREATION_ERROR:String = "creationError";
|
||||
|
||||
private var _netConnection:NetConnection;
|
||||
|
||||
private var _resource:URLResource;
|
||||
|
||||
private var _mediaError:MediaError;
|
||||
|
||||
public function NetConnectionFactoryEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:NetConnection = null, param5:URLResource = null, param6:MediaError = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_netConnection = param4;
|
||||
_resource = param5;
|
||||
_mediaError = param6;
|
||||
}
|
||||
|
||||
public function get netConnection() : NetConnection
|
||||
{
|
||||
return _netConnection;
|
||||
}
|
||||
|
||||
public function get resource() : URLResource
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public function get mediaError() : MediaError
|
||||
{
|
||||
return _mediaError;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new NetConnectionFactoryEvent(type,bubbles,cancelable,_netConnection,_resource,_mediaError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class PlayEvent extends Event
|
||||
{
|
||||
|
||||
public static const CAN_PAUSE_CHANGE:String = "canPauseChange";
|
||||
|
||||
public static const PLAY_STATE_CHANGE:String = "playStateChange";
|
||||
|
||||
private var _playState:String;
|
||||
|
||||
private var _canPause:Boolean;
|
||||
|
||||
public function PlayEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:String = null, param5:Boolean = false)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_playState = param4;
|
||||
_canPause = param5;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new PlayEvent(type,bubbles,cancelable,playState,canPause);
|
||||
}
|
||||
|
||||
public function get playState() : String
|
||||
{
|
||||
return _playState;
|
||||
}
|
||||
|
||||
public function get canPause() : Boolean
|
||||
{
|
||||
return _canPause;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
|
||||
public class PluginManagerEvent extends Event
|
||||
{
|
||||
|
||||
public static const PLUGIN_LOAD:String = "pluginLoad";
|
||||
|
||||
public static const PLUGIN_LOAD_ERROR:String = "pluginLoadError";
|
||||
|
||||
private var _resource:MediaResourceBase;
|
||||
|
||||
public function PluginManagerEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:MediaResourceBase = null)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_resource = param4;
|
||||
}
|
||||
|
||||
public function get resource() : MediaResourceBase
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new PluginManagerEvent(type,bubbles,cancelable,_resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class SeekEvent extends Event
|
||||
{
|
||||
|
||||
public static const SEEKING_CHANGE:String = "seekingChange";
|
||||
|
||||
private var _seeking:Boolean = false;
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
public function SeekEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Boolean = false, param5:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_seeking = param4;
|
||||
_time = param5;
|
||||
}
|
||||
|
||||
public function get seeking() : Boolean
|
||||
{
|
||||
return _seeking;
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new SeekEvent(type,bubbles,cancelable,_seeking,_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class TimeEvent extends Event
|
||||
{
|
||||
|
||||
public static const CURRENT_TIME_CHANGE:String = "currentTimeChange";
|
||||
|
||||
public static const DURATION_CHANGE:String = "durationChange";
|
||||
|
||||
public static const COMPLETE:String = "complete";
|
||||
|
||||
private var _time:Number;
|
||||
|
||||
public function TimeEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Number = NaN)
|
||||
{
|
||||
super(param1,param2,param3);
|
||||
_time = param4;
|
||||
}
|
||||
|
||||
public function get time() : Number
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new TimeEvent(type,bubbles,cancelable,time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.osmf.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.metadata.TimelineMarker;
|
||||
|
||||
public class TimelineMetadataEvent extends MetadataEvent
|
||||
{
|
||||
|
||||
public static const MARKER_TIME_REACHED:String = "markerTimeReached";
|
||||
|
||||
public static const MARKER_DURATION_REACHED:String = "markerDurationReached";
|
||||
|
||||
public static const MARKER_ADD:String = "markerAdd";
|
||||
|
||||
public static const MARKER_REMOVE:String = "markerRemove";
|
||||
|
||||
private var _marker:TimelineMarker;
|
||||
|
||||
public function TimelineMetadataEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:TimelineMarker = null)
|
||||
{
|
||||
super(param1,param2,param3,"" + param4.time,param4);
|
||||
_marker = param4;
|
||||
}
|
||||
|
||||
public function get marker() : TimelineMarker
|
||||
{
|
||||
return _marker;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new TimelineMetadataEvent(type,bubbles,cancelable,_marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class AbsoluteLayoutMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const X:String = "x";
|
||||
|
||||
public static const Y:String = "y";
|
||||
|
||||
public static const WIDTH:String = "width";
|
||||
|
||||
public static const HEIGHT:String = "height";
|
||||
|
||||
private var _x:Number;
|
||||
|
||||
private var _y:Number;
|
||||
|
||||
private var _width:Number;
|
||||
|
||||
private var _height:Number;
|
||||
|
||||
public function AbsoluteLayoutMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "x")
|
||||
{
|
||||
return x;
|
||||
}
|
||||
if(param1 == "y")
|
||||
{
|
||||
return y;
|
||||
}
|
||||
if(param1 == "width")
|
||||
{
|
||||
return width;
|
||||
}
|
||||
if(param1 == "height")
|
||||
{
|
||||
return height;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get x() : Number
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
public function set x(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_x != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"x",param1,_x);
|
||||
_x = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get y() : Number
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
public function set y(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_y != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"y",param1,_y);
|
||||
_y = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get width() : Number
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
public function set width(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_width != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"width",param1,_width);
|
||||
_width = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get height() : Number
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
public function set height(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_height != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"height",param1,_height);
|
||||
_height = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class AnchorLayoutMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const LEFT:String = "left";
|
||||
|
||||
public static const TOP:String = "top";
|
||||
|
||||
public static const RIGHT:String = "right";
|
||||
|
||||
public static const BOTTOM:String = "bottom";
|
||||
|
||||
private var _left:Number;
|
||||
|
||||
private var _top:Number;
|
||||
|
||||
private var _right:Number;
|
||||
|
||||
private var _bottom:Number;
|
||||
|
||||
public function AnchorLayoutMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "left")
|
||||
{
|
||||
return left;
|
||||
}
|
||||
if(param1 == "top")
|
||||
{
|
||||
return top;
|
||||
}
|
||||
if(param1 == "right")
|
||||
{
|
||||
return right;
|
||||
}
|
||||
if(param1 == "bottom")
|
||||
{
|
||||
return bottom;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get left() : Number
|
||||
{
|
||||
return _left;
|
||||
}
|
||||
|
||||
public function set left(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_left != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"left",param1,_left);
|
||||
_left = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get top() : Number
|
||||
{
|
||||
return _top;
|
||||
}
|
||||
|
||||
public function set top(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_top != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"top",param1,_top);
|
||||
_top = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get right() : Number
|
||||
{
|
||||
return _right;
|
||||
}
|
||||
|
||||
public function set right(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_right != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"right",param1,_right);
|
||||
_right = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get bottom() : Number
|
||||
{
|
||||
return _bottom;
|
||||
}
|
||||
|
||||
public function set bottom(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_bottom != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"bottom",param1,_bottom);
|
||||
_bottom = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class BinarySearch
|
||||
{
|
||||
|
||||
public function BinarySearch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function search(param1:Object, param2:Function, param3:*, param4:int = 0, param5:int = -2147483648) : int
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:* = undefined;
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
var _loc6_:int = -param4;
|
||||
param5 = int(param5 == -2147483648 ? param1.length - 1 : param5);
|
||||
if(param1.length > 0 && param4 <= param5)
|
||||
{
|
||||
_loc8_ = (param4 + param5) / 2;
|
||||
_loc7_ = param1[_loc8_];
|
||||
switch(param2(param3,_loc7_))
|
||||
{
|
||||
case -1:
|
||||
_loc6_ = search(param1,param2,param3,param4,_loc8_ - 1);
|
||||
break;
|
||||
case 0:
|
||||
_loc6_ = _loc8_;
|
||||
break;
|
||||
case 1:
|
||||
_loc6_ = search(param1,param2,param3,_loc8_ + 1,param5);
|
||||
}
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class BoxAttributesMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const RELATIVE_SUM:String = "relativeSum";
|
||||
|
||||
public static const ABSOLUTE_SUM:String = "absoluteSum";
|
||||
|
||||
private var _relativeSum:Number;
|
||||
|
||||
private var _absoluteSum:Number;
|
||||
|
||||
public function BoxAttributesMetadata()
|
||||
{
|
||||
super();
|
||||
_relativeSum = 0;
|
||||
_absoluteSum = 0;
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "relativeSum")
|
||||
{
|
||||
return relativeSum;
|
||||
}
|
||||
if(param1 == "absoluteSum")
|
||||
{
|
||||
return absoluteSum;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get relativeSum() : Number
|
||||
{
|
||||
return _relativeSum;
|
||||
}
|
||||
|
||||
public function set relativeSum(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_relativeSum != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"relativeSum",param1,_relativeSum);
|
||||
_relativeSum = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get absoluteSum() : Number
|
||||
{
|
||||
return _absoluteSum;
|
||||
}
|
||||
|
||||
public function set absoluteSum(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_absoluteSum != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"absoluteSum",param1,_absoluteSum);
|
||||
_absoluteSum = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
public final class HorizontalAlign
|
||||
{
|
||||
|
||||
public static const LEFT:String = "left";
|
||||
|
||||
public static const CENTER:String = "center";
|
||||
|
||||
public static const RIGHT:String = "right";
|
||||
|
||||
public function HorizontalAlign()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.IEventDispatcher;
|
||||
|
||||
public interface ILayoutTarget extends IEventDispatcher
|
||||
{
|
||||
|
||||
function get displayObject() : DisplayObject;
|
||||
|
||||
function get layoutMetadata() : LayoutMetadata;
|
||||
|
||||
function get measuredWidth() : Number;
|
||||
|
||||
function get measuredHeight() : Number;
|
||||
|
||||
function measure(param1:Boolean = true) : void;
|
||||
|
||||
function layout(param1:Number, param2:Number, param3:Boolean = true) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class LayoutAttributesMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const INDEX:String = "index";
|
||||
|
||||
public static const SCALE_MODE:String = "scaleMode";
|
||||
|
||||
public static const VERTICAL_ALIGN:String = "verticalAlign";
|
||||
|
||||
public static const HORIZONTAL_ALIGN:String = "horizontalAlign";
|
||||
|
||||
public static const SNAP_TO_PIXEL:String = "snapToPixel";
|
||||
|
||||
public static const MODE:String = "layoutMode";
|
||||
|
||||
public static const INCLUDE_IN_LAYOUT:String = "includeInLayout";
|
||||
|
||||
private var _index:Number = NaN;
|
||||
|
||||
private var _scaleMode:String;
|
||||
|
||||
private var _verticalAlign:String;
|
||||
|
||||
private var _horizontalAlign:String;
|
||||
|
||||
private var _snapToPixel:Boolean;
|
||||
|
||||
private var _layoutMode:String;
|
||||
|
||||
private var _includeInLayout:Boolean;
|
||||
|
||||
public function LayoutAttributesMetadata()
|
||||
{
|
||||
super();
|
||||
_verticalAlign = null;
|
||||
_horizontalAlign = null;
|
||||
_scaleMode = null;
|
||||
_snapToPixel = true;
|
||||
_layoutMode = "none";
|
||||
_includeInLayout = true;
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "index")
|
||||
{
|
||||
return index;
|
||||
}
|
||||
if(param1 == "scaleMode")
|
||||
{
|
||||
return scaleMode;
|
||||
}
|
||||
if(param1 == "verticalAlign")
|
||||
{
|
||||
return verticalAlign;
|
||||
}
|
||||
if(param1 == "horizontalAlign")
|
||||
{
|
||||
return horizontalAlign;
|
||||
}
|
||||
if(param1 == "snapToPixel")
|
||||
{
|
||||
return snapToPixel;
|
||||
}
|
||||
if(param1 == "includeInLayout")
|
||||
{
|
||||
return snapToPixel;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get index() : Number
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
|
||||
public function set index(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_index != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"index",param1,_index);
|
||||
_index = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get scaleMode() : String
|
||||
{
|
||||
return _scaleMode;
|
||||
}
|
||||
|
||||
public function set scaleMode(param1:String) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_scaleMode != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"scaleMode",param1,_scaleMode);
|
||||
_scaleMode = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get verticalAlign() : String
|
||||
{
|
||||
return _verticalAlign;
|
||||
}
|
||||
|
||||
public function set verticalAlign(param1:String) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_verticalAlign != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"verticalAlign",param1,_verticalAlign);
|
||||
_verticalAlign = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get horizontalAlign() : String
|
||||
{
|
||||
return _horizontalAlign;
|
||||
}
|
||||
|
||||
public function set horizontalAlign(param1:String) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_horizontalAlign != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"horizontalAlign",param1,_horizontalAlign);
|
||||
_horizontalAlign = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get snapToPixel() : Boolean
|
||||
{
|
||||
return _snapToPixel;
|
||||
}
|
||||
|
||||
public function set snapToPixel(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_snapToPixel != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"snapToPixel",param1,_snapToPixel);
|
||||
_snapToPixel = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get layoutMode() : String
|
||||
{
|
||||
return _layoutMode;
|
||||
}
|
||||
|
||||
public function set layoutMode(param1:String) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_layoutMode != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"layoutMode",param1,_layoutMode);
|
||||
_layoutMode = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get includeInLayout() : Boolean
|
||||
{
|
||||
return _includeInLayout;
|
||||
}
|
||||
|
||||
public function set includeInLayout(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_includeInLayout != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"includeInLayout",param1,_layoutMode);
|
||||
_includeInLayout = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.MetadataSynthesizer;
|
||||
import org.osmf.metadata.NullMetadataSynthesizer;
|
||||
|
||||
public class LayoutMetadata extends Metadata
|
||||
{
|
||||
|
||||
public static const LAYOUT_NAMESPACE:String = "http://www.osmf.org/layout/1.0";
|
||||
|
||||
private const SYNTHESIZER:NullMetadataSynthesizer = new NullMetadataSynthesizer();
|
||||
|
||||
public function LayoutMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get index() : Number
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.index : NaN;
|
||||
}
|
||||
|
||||
public function set index(param1:Number) : void
|
||||
{
|
||||
eagerAttributes.index = param1;
|
||||
}
|
||||
|
||||
public function get scaleMode() : String
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.scaleMode : null;
|
||||
}
|
||||
|
||||
public function set scaleMode(param1:String) : void
|
||||
{
|
||||
eagerAttributes.scaleMode = param1;
|
||||
}
|
||||
|
||||
public function get horizontalAlign() : String
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.horizontalAlign : null;
|
||||
}
|
||||
|
||||
public function set horizontalAlign(param1:String) : void
|
||||
{
|
||||
eagerAttributes.horizontalAlign = param1;
|
||||
}
|
||||
|
||||
public function get verticalAlign() : String
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.verticalAlign : null;
|
||||
}
|
||||
|
||||
public function set verticalAlign(param1:String) : void
|
||||
{
|
||||
eagerAttributes.verticalAlign = param1;
|
||||
}
|
||||
|
||||
public function get snapToPixel() : Boolean
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.snapToPixel : true;
|
||||
}
|
||||
|
||||
public function set snapToPixel(param1:Boolean) : void
|
||||
{
|
||||
eagerAttributes.snapToPixel = param1;
|
||||
}
|
||||
|
||||
public function get layoutMode() : String
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.layoutMode : "none";
|
||||
}
|
||||
|
||||
public function set layoutMode(param1:String) : void
|
||||
{
|
||||
eagerAttributes.layoutMode = param1;
|
||||
}
|
||||
|
||||
public function get includeInLayout() : Boolean
|
||||
{
|
||||
return lazyAttributes ? lazyAttributes.includeInLayout : true;
|
||||
}
|
||||
|
||||
public function set includeInLayout(param1:Boolean) : void
|
||||
{
|
||||
eagerAttributes.includeInLayout = param1;
|
||||
}
|
||||
|
||||
public function get x() : Number
|
||||
{
|
||||
return lazyAbsolute ? lazyAbsolute.x : NaN;
|
||||
}
|
||||
|
||||
public function set x(param1:Number) : void
|
||||
{
|
||||
eagerAbsolute.x = param1;
|
||||
}
|
||||
|
||||
public function get y() : Number
|
||||
{
|
||||
return lazyAbsolute ? lazyAbsolute.y : NaN;
|
||||
}
|
||||
|
||||
public function set y(param1:Number) : void
|
||||
{
|
||||
eagerAbsolute.y = param1;
|
||||
}
|
||||
|
||||
public function get width() : Number
|
||||
{
|
||||
return lazyAbsolute ? lazyAbsolute.width : NaN;
|
||||
}
|
||||
|
||||
public function set width(param1:Number) : void
|
||||
{
|
||||
eagerAbsolute.width = param1;
|
||||
}
|
||||
|
||||
public function get height() : Number
|
||||
{
|
||||
return lazyAbsolute ? lazyAbsolute.height : NaN;
|
||||
}
|
||||
|
||||
public function set height(param1:Number) : void
|
||||
{
|
||||
eagerAbsolute.height = param1;
|
||||
}
|
||||
|
||||
public function get percentX() : Number
|
||||
{
|
||||
return lazyRelative ? lazyRelative.x : NaN;
|
||||
}
|
||||
|
||||
public function set percentX(param1:Number) : void
|
||||
{
|
||||
eagerRelative.x = param1;
|
||||
}
|
||||
|
||||
public function get percentY() : Number
|
||||
{
|
||||
return lazyRelative ? lazyRelative.y : NaN;
|
||||
}
|
||||
|
||||
public function set percentY(param1:Number) : void
|
||||
{
|
||||
eagerRelative.y = param1;
|
||||
}
|
||||
|
||||
public function get percentWidth() : Number
|
||||
{
|
||||
return lazyRelative ? lazyRelative.width : NaN;
|
||||
}
|
||||
|
||||
public function set percentWidth(param1:Number) : void
|
||||
{
|
||||
eagerRelative.width = param1;
|
||||
}
|
||||
|
||||
public function get percentHeight() : Number
|
||||
{
|
||||
return lazyRelative ? lazyRelative.height : NaN;
|
||||
}
|
||||
|
||||
public function set percentHeight(param1:Number) : void
|
||||
{
|
||||
eagerRelative.height = param1;
|
||||
}
|
||||
|
||||
public function get left() : Number
|
||||
{
|
||||
return lazyAnchor ? lazyAnchor.left : NaN;
|
||||
}
|
||||
|
||||
public function set left(param1:Number) : void
|
||||
{
|
||||
eagerAnchor.left = param1;
|
||||
}
|
||||
|
||||
public function get top() : Number
|
||||
{
|
||||
return lazyAnchor ? lazyAnchor.top : NaN;
|
||||
}
|
||||
|
||||
public function set top(param1:Number) : void
|
||||
{
|
||||
eagerAnchor.top = param1;
|
||||
}
|
||||
|
||||
public function get right() : Number
|
||||
{
|
||||
return lazyAnchor ? lazyAnchor.right : NaN;
|
||||
}
|
||||
|
||||
public function set right(param1:Number) : void
|
||||
{
|
||||
eagerAnchor.right = param1;
|
||||
}
|
||||
|
||||
public function get bottom() : Number
|
||||
{
|
||||
return lazyAnchor ? lazyAnchor.bottom : NaN;
|
||||
}
|
||||
|
||||
public function set bottom(param1:Number) : void
|
||||
{
|
||||
eagerAnchor.bottom = param1;
|
||||
}
|
||||
|
||||
public function get paddingLeft() : Number
|
||||
{
|
||||
return lazyPadding ? lazyPadding.left : NaN;
|
||||
}
|
||||
|
||||
public function set paddingLeft(param1:Number) : void
|
||||
{
|
||||
eagerPadding.left = param1;
|
||||
}
|
||||
|
||||
public function get paddingTop() : Number
|
||||
{
|
||||
return lazyPadding ? lazyPadding.top : NaN;
|
||||
}
|
||||
|
||||
public function set paddingTop(param1:Number) : void
|
||||
{
|
||||
eagerPadding.top = param1;
|
||||
}
|
||||
|
||||
public function get paddingRight() : Number
|
||||
{
|
||||
return lazyPadding ? lazyPadding.right : NaN;
|
||||
}
|
||||
|
||||
public function set paddingRight(param1:Number) : void
|
||||
{
|
||||
eagerPadding.right = param1;
|
||||
}
|
||||
|
||||
public function get paddingBottom() : Number
|
||||
{
|
||||
return lazyPadding ? lazyPadding.bottom : NaN;
|
||||
}
|
||||
|
||||
public function set paddingBottom(param1:Number) : void
|
||||
{
|
||||
eagerPadding.bottom = param1;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "abs [" + x + ", " + y + ", " + width + ", " + height + "] " + "rel [" + percentX + ", " + percentY + ", " + percentWidth + ", " + percentHeight + "] " + "anch (" + left + ", " + top + ")(" + right + ", " + bottom + ") " + "pad [" + paddingLeft + ", " + paddingTop + ", " + paddingRight + ", " + paddingBottom + "] " + "layoutMode: " + layoutMode + " " + "index: " + index + " " + "scale: " + scaleMode + " " + "valign: " + verticalAlign + " " + "halign: " + horizontalAlign + " " + "snap: " + snapToPixel;
|
||||
}
|
||||
|
||||
override public function get synthesizer() : MetadataSynthesizer
|
||||
{
|
||||
return SYNTHESIZER;
|
||||
}
|
||||
|
||||
private function get lazyAttributes() : LayoutAttributesMetadata
|
||||
{
|
||||
return getValue("http://www.osmf.org/layout/attributes/1.0") as LayoutAttributesMetadata;
|
||||
}
|
||||
|
||||
private function get eagerAttributes() : LayoutAttributesMetadata
|
||||
{
|
||||
var _loc1_:LayoutAttributesMetadata = lazyAttributes;
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_loc1_ = new LayoutAttributesMetadata();
|
||||
addValue("http://www.osmf.org/layout/attributes/1.0",_loc1_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get lazyAbsolute() : AbsoluteLayoutMetadata
|
||||
{
|
||||
return getValue("http://www.osmf.org/layout/absolute/1.0") as AbsoluteLayoutMetadata;
|
||||
}
|
||||
|
||||
private function get eagerAbsolute() : AbsoluteLayoutMetadata
|
||||
{
|
||||
var _loc1_:AbsoluteLayoutMetadata = lazyAbsolute;
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_loc1_ = new AbsoluteLayoutMetadata();
|
||||
addValue("http://www.osmf.org/layout/absolute/1.0",_loc1_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get lazyRelative() : RelativeLayoutMetadata
|
||||
{
|
||||
return getValue("http://www.osmf.org/layout/relative/1.0") as RelativeLayoutMetadata;
|
||||
}
|
||||
|
||||
private function get eagerRelative() : RelativeLayoutMetadata
|
||||
{
|
||||
var _loc1_:RelativeLayoutMetadata = lazyRelative;
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_loc1_ = new RelativeLayoutMetadata();
|
||||
addValue("http://www.osmf.org/layout/relative/1.0",_loc1_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get lazyAnchor() : AnchorLayoutMetadata
|
||||
{
|
||||
return getValue("http://www.osmf.org/layout/anchor/1.0") as AnchorLayoutMetadata;
|
||||
}
|
||||
|
||||
private function get eagerAnchor() : AnchorLayoutMetadata
|
||||
{
|
||||
var _loc1_:AnchorLayoutMetadata = lazyAnchor;
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_loc1_ = new AnchorLayoutMetadata();
|
||||
addValue("http://www.osmf.org/layout/anchor/1.0",_loc1_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function get lazyPadding() : PaddingLayoutMetadata
|
||||
{
|
||||
return getValue("http://www.osmf.org/layout/padding/1.0") as PaddingLayoutMetadata;
|
||||
}
|
||||
|
||||
private function get eagerPadding() : PaddingLayoutMetadata
|
||||
{
|
||||
var _loc1_:PaddingLayoutMetadata = lazyPadding;
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_loc1_ = new PaddingLayoutMetadata();
|
||||
addValue("http://www.osmf.org/layout/padding/1.0",_loc1_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
public final class LayoutMode
|
||||
{
|
||||
|
||||
public static const NONE:String = "none";
|
||||
|
||||
public static const VERTICAL:String = "vertical";
|
||||
|
||||
public static const HORIZONTAL:String = "horizontal";
|
||||
|
||||
public function LayoutMode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,453 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.metadata.MetadataWatcher;
|
||||
|
||||
public class LayoutRenderer extends LayoutRendererBase
|
||||
{
|
||||
|
||||
private static const X:int = 1;
|
||||
|
||||
private static const Y:int = 2;
|
||||
|
||||
private static const WIDTH:int = 4;
|
||||
|
||||
private static const HEIGHT:int = 8;
|
||||
|
||||
private static const POSITION:int = 3;
|
||||
|
||||
private static const DIMENSIONS:int = 12;
|
||||
|
||||
private static const ALL:int = 15;
|
||||
|
||||
private static const USED_METADATAS:Vector.<String> = new Vector.<String>(5,true);
|
||||
|
||||
USED_METADATAS[0] = "http://www.osmf.org/layout/absolute/1.0";
|
||||
USED_METADATAS[1] = "http://www.osmf.org/layout/relative/1.0";
|
||||
USED_METADATAS[2] = "http://www.osmf.org/layout/anchor/1.0";
|
||||
USED_METADATAS[3] = "http://www.osmf.org/layout/padding/1.0";
|
||||
USED_METADATAS[4] = "http://www.osmf.org/layout/attributes/1.0";
|
||||
|
||||
private var layoutMode:String = "none";
|
||||
|
||||
private var lastCalculatedBounds:Rectangle;
|
||||
|
||||
private var targetMetadataWatchers:Dictionary = new Dictionary();
|
||||
|
||||
private var containerAbsoluteWatcher:MetadataWatcher;
|
||||
|
||||
private var containerAttributesWatcher:MetadataWatcher;
|
||||
|
||||
public function LayoutRenderer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override protected function get usedMetadatas() : Vector.<String>
|
||||
{
|
||||
return USED_METADATAS;
|
||||
}
|
||||
|
||||
override protected function processContainerChange(param1:ILayoutTarget, param2:ILayoutTarget) : void
|
||||
{
|
||||
var oldContainer:ILayoutTarget = param1;
|
||||
var newContainer:ILayoutTarget = param2;
|
||||
if(oldContainer)
|
||||
{
|
||||
containerAbsoluteWatcher.unwatch();
|
||||
containerAttributesWatcher.unwatch();
|
||||
}
|
||||
if(newContainer)
|
||||
{
|
||||
containerAbsoluteWatcher = new MetadataWatcher(newContainer.layoutMetadata,"http://www.osmf.org/layout/absolute/1.0",null,function(... rest):void
|
||||
{
|
||||
invalidate();
|
||||
});
|
||||
containerAbsoluteWatcher.watch();
|
||||
containerAttributesWatcher = new MetadataWatcher(newContainer.layoutMetadata,"http://www.osmf.org/layout/attributes/1.0",null,function(param1:LayoutAttributesMetadata):void
|
||||
{
|
||||
layoutMode = param1 ? param1.layoutMode : "none";
|
||||
invalidate();
|
||||
});
|
||||
containerAttributesWatcher.watch();
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
override protected function processUpdateMediaDisplayBegin(param1:Vector.<ILayoutTarget>) : void
|
||||
{
|
||||
lastCalculatedBounds = null;
|
||||
}
|
||||
|
||||
override protected function processUpdateMediaDisplayEnd() : void
|
||||
{
|
||||
lastCalculatedBounds = null;
|
||||
}
|
||||
|
||||
override protected function processTargetAdded(param1:ILayoutTarget) : void
|
||||
{
|
||||
var watcher:MetadataWatcher;
|
||||
var target:ILayoutTarget = param1;
|
||||
var attributes:LayoutAttributesMetadata = target.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/1.0") as LayoutAttributesMetadata;
|
||||
var relative:RelativeLayoutMetadata = target.layoutMetadata.getValue("http://www.osmf.org/layout/relative/1.0") as RelativeLayoutMetadata;
|
||||
if(layoutMode == "none" && relative == null && attributes == null && target.layoutMetadata.getValue("http://www.osmf.org/layout/absolute/1.0") == null && target.layoutMetadata.getValue("http://www.osmf.org/layout/anchor/1.0") == null)
|
||||
{
|
||||
relative = new RelativeLayoutMetadata();
|
||||
relative.width = 100;
|
||||
relative.height = 100;
|
||||
target.layoutMetadata.addValue("http://www.osmf.org/layout/relative/1.0",relative);
|
||||
attributes = new LayoutAttributesMetadata();
|
||||
attributes.scaleMode ||= "letterbox";
|
||||
attributes.verticalAlign ||= "middle";
|
||||
attributes.horizontalAlign ||= "center";
|
||||
target.layoutMetadata.addValue("http://www.osmf.org/layout/attributes/1.0",attributes);
|
||||
}
|
||||
watcher = new MetadataWatcher(target.layoutMetadata,"http://www.osmf.org/layout/attributes/1.0","index",function(... rest):void
|
||||
{
|
||||
updateTargetOrder(target);
|
||||
});
|
||||
watcher.watch();
|
||||
targetMetadataWatchers[target] = watcher;
|
||||
}
|
||||
|
||||
override protected function processTargetRemoved(param1:ILayoutTarget) : void
|
||||
{
|
||||
var _loc2_:MetadataWatcher = targetMetadataWatchers[param1];
|
||||
delete targetMetadataWatchers[param1];
|
||||
_loc2_.unwatch();
|
||||
_loc2_ = null;
|
||||
}
|
||||
|
||||
override protected function compareTargets(param1:ILayoutTarget, param2:ILayoutTarget) : Number
|
||||
{
|
||||
var _loc4_:LayoutAttributesMetadata = param1.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/1.0") as LayoutAttributesMetadata;
|
||||
var _loc3_:LayoutAttributesMetadata = param2.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/1.0") as LayoutAttributesMetadata;
|
||||
var _loc6_:* = _loc4_ ? _loc4_.index : NaN;
|
||||
var _loc5_:* = _loc3_ ? _loc3_.index : NaN;
|
||||
if(isNaN(_loc6_) && isNaN(_loc5_))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(!_loc6_)
|
||||
{
|
||||
_loc6_ = 0;
|
||||
}
|
||||
if(!_loc5_)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
}
|
||||
return _loc6_ < _loc5_ ? -1 : (_loc6_ > _loc5_ ? 1 : 0);
|
||||
}
|
||||
|
||||
override protected function calculateTargetBounds(param1:ILayoutTarget, param2:Number, param3:Number) : Rectangle
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:BoxAttributesMetadata = null;
|
||||
var _loc16_:RelativeLayoutMetadata = null;
|
||||
var _loc8_:AnchorLayoutMetadata = null;
|
||||
var _loc13_:Point = null;
|
||||
var _loc15_:LayoutAttributesMetadata = param1.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/1.0") as LayoutAttributesMetadata || new LayoutAttributesMetadata();
|
||||
if(_loc15_.includeInLayout == false)
|
||||
{
|
||||
return new Rectangle();
|
||||
}
|
||||
var _loc12_:Rectangle = new Rectangle(0,0,param1.measuredWidth,param1.measuredHeight);
|
||||
var _loc14_:AbsoluteLayoutMetadata = param1.layoutMetadata.getValue("http://www.osmf.org/layout/absolute/1.0") as AbsoluteLayoutMetadata;
|
||||
var _loc9_:Number = 0;
|
||||
var _loc10_:Number = 0;
|
||||
var _loc11_:int = 15;
|
||||
if(_loc14_)
|
||||
{
|
||||
if(!isNaN(_loc14_.x))
|
||||
{
|
||||
_loc12_.x = _loc14_.x;
|
||||
_loc11_ ^= 1;
|
||||
}
|
||||
if(!isNaN(_loc14_.y))
|
||||
{
|
||||
_loc12_.y = _loc14_.y;
|
||||
_loc11_ ^= 2;
|
||||
}
|
||||
if(!isNaN(_loc14_.width))
|
||||
{
|
||||
_loc12_.width = _loc14_.width;
|
||||
_loc11_ ^= 4;
|
||||
}
|
||||
if(!isNaN(_loc14_.height))
|
||||
{
|
||||
_loc12_.height = _loc14_.height;
|
||||
_loc11_ ^= 8;
|
||||
}
|
||||
}
|
||||
if(_loc11_ != 0)
|
||||
{
|
||||
_loc16_ = param1.layoutMetadata.getValue("http://www.osmf.org/layout/relative/1.0") as RelativeLayoutMetadata;
|
||||
if(_loc16_)
|
||||
{
|
||||
if(_loc11_ & 1 && !isNaN(_loc16_.x))
|
||||
{
|
||||
_loc12_.x = param2 * _loc16_.x / 100 || 0;
|
||||
_loc11_ ^= 1;
|
||||
}
|
||||
if(_loc11_ & 4 && !isNaN(_loc16_.width))
|
||||
{
|
||||
if(layoutMode == "horizontal")
|
||||
{
|
||||
_loc7_ = container.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/box/1.0") as BoxAttributesMetadata || new BoxAttributesMetadata();
|
||||
_loc12_.width = Math.max(0,param2 - _loc7_.absoluteSum) * _loc16_.width / _loc7_.relativeSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.width = param2 * _loc16_.width / 100;
|
||||
}
|
||||
_loc11_ ^= 4;
|
||||
}
|
||||
if(_loc11_ & 2 && !isNaN(_loc16_.y))
|
||||
{
|
||||
_loc12_.y = param3 * _loc16_.y / 100 || 0;
|
||||
_loc11_ ^= 2;
|
||||
}
|
||||
if(_loc11_ & 8 && !isNaN(_loc16_.height))
|
||||
{
|
||||
if(layoutMode == "vertical")
|
||||
{
|
||||
_loc7_ = container.layoutMetadata.getValue("http://www.osmf.org/layout/attributes/box/1.0") as BoxAttributesMetadata || new BoxAttributesMetadata();
|
||||
_loc12_.height = Math.max(0,param3 - _loc7_.absoluteSum) * _loc16_.height / _loc7_.relativeSum;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.height = param3 * _loc16_.height / 100;
|
||||
}
|
||||
_loc11_ ^= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc11_ != 0)
|
||||
{
|
||||
_loc8_ = param1.layoutMetadata.getValue("http://www.osmf.org/layout/anchor/1.0") as AnchorLayoutMetadata;
|
||||
if(_loc8_)
|
||||
{
|
||||
if(_loc11_ & 1 && !isNaN(_loc8_.left))
|
||||
{
|
||||
_loc12_.x = _loc8_.left;
|
||||
_loc11_ ^= 1;
|
||||
}
|
||||
if(_loc11_ & 2 && !isNaN(_loc8_.top))
|
||||
{
|
||||
_loc12_.y = _loc8_.top;
|
||||
_loc11_ ^= 2;
|
||||
}
|
||||
if(!isNaN(_loc8_.right) && param2)
|
||||
{
|
||||
if(_loc11_ & 1 && !(_loc11_ & 4))
|
||||
{
|
||||
_loc12_.x = Math.max(0,param2 - _loc12_.width - _loc8_.right);
|
||||
_loc11_ ^= 1;
|
||||
}
|
||||
else if(_loc11_ & 4 && !(_loc11_ & 1))
|
||||
{
|
||||
_loc12_.width = Math.max(0,param2 - _loc8_.right - _loc12_.x);
|
||||
_loc11_ ^= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.x = Math.max(0,param2 - param1.measuredWidth - _loc8_.right);
|
||||
_loc11_ ^= 1;
|
||||
}
|
||||
_loc9_ += _loc8_.right;
|
||||
}
|
||||
if(!isNaN(_loc8_.bottom) && param3)
|
||||
{
|
||||
if(_loc11_ & 2 && !(_loc11_ & 8))
|
||||
{
|
||||
_loc12_.y = Math.max(0,param3 - _loc12_.height - _loc8_.bottom);
|
||||
_loc11_ ^= 2;
|
||||
}
|
||||
else if(_loc11_ & 8 && !(_loc11_ & 2))
|
||||
{
|
||||
_loc12_.height = Math.max(0,param3 - _loc8_.bottom - _loc12_.y);
|
||||
_loc11_ ^= 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.y = Math.max(0,param3 - param1.measuredHeight - _loc8_.bottom);
|
||||
_loc11_ ^= 2;
|
||||
}
|
||||
_loc10_ += _loc8_.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loc4_:PaddingLayoutMetadata = param1.layoutMetadata.getValue("http://www.osmf.org/layout/padding/1.0") as PaddingLayoutMetadata;
|
||||
if(_loc4_)
|
||||
{
|
||||
if(!isNaN(_loc4_.left))
|
||||
{
|
||||
_loc12_.x += _loc4_.left;
|
||||
}
|
||||
if(!isNaN(_loc4_.top))
|
||||
{
|
||||
_loc12_.y += _loc4_.top;
|
||||
}
|
||||
if(!isNaN(_loc4_.right) && !(_loc11_ & 4))
|
||||
{
|
||||
_loc12_.width -= _loc4_.right + (_loc4_.left || 0);
|
||||
}
|
||||
if(!isNaN(_loc4_.bottom) && !(_loc11_ & 8))
|
||||
{
|
||||
_loc12_.height -= _loc4_.bottom + (_loc4_.top || 0);
|
||||
}
|
||||
}
|
||||
if(_loc15_.scaleMode)
|
||||
{
|
||||
if(!(_loc11_ & 4 || _loc11_ & 8) && param1.measuredWidth && param1.measuredHeight)
|
||||
{
|
||||
_loc13_ = ScaleModeUtils.getScaledSize(_loc15_.scaleMode,_loc12_.width,_loc12_.height,param1.measuredWidth,param1.measuredHeight);
|
||||
_loc5_ = _loc12_.width - _loc13_.x;
|
||||
_loc6_ = _loc12_.height - _loc13_.y;
|
||||
_loc12_.width = _loc13_.x;
|
||||
_loc12_.height = _loc13_.y;
|
||||
}
|
||||
}
|
||||
if(layoutMode != "horizontal")
|
||||
{
|
||||
if(!_loc5_)
|
||||
{
|
||||
_loc5_ = param2 - (_loc12_.x || 0) - (_loc12_.width || 0) - _loc9_;
|
||||
}
|
||||
}
|
||||
if(layoutMode != "vertical")
|
||||
{
|
||||
if(!_loc6_)
|
||||
{
|
||||
_loc6_ = param3 - (_loc12_.y || 0) - (_loc12_.height || 0) - _loc10_;
|
||||
}
|
||||
}
|
||||
if(_loc6_)
|
||||
{
|
||||
switch(_loc15_.verticalAlign)
|
||||
{
|
||||
case null:
|
||||
case "top":
|
||||
break;
|
||||
case "middle":
|
||||
_loc12_.y += _loc6_ / 2;
|
||||
break;
|
||||
case "bottom":
|
||||
_loc12_.y += _loc6_;
|
||||
}
|
||||
}
|
||||
if(_loc5_)
|
||||
{
|
||||
switch(_loc15_.horizontalAlign)
|
||||
{
|
||||
case null:
|
||||
case "left":
|
||||
break;
|
||||
case "center":
|
||||
_loc12_.x += _loc5_ / 2;
|
||||
break;
|
||||
case "right":
|
||||
_loc12_.x += _loc5_;
|
||||
}
|
||||
}
|
||||
if(_loc15_.snapToPixel)
|
||||
{
|
||||
_loc12_.x = Math.round(_loc12_.x);
|
||||
_loc12_.y = Math.round(_loc12_.y);
|
||||
_loc12_.width = Math.round(_loc12_.width);
|
||||
_loc12_.height = Math.round(_loc12_.height);
|
||||
}
|
||||
if(layoutMode == "horizontal" || layoutMode == "vertical")
|
||||
{
|
||||
if(lastCalculatedBounds != null)
|
||||
{
|
||||
if(layoutMode == "horizontal")
|
||||
{
|
||||
_loc12_.x = lastCalculatedBounds.x + lastCalculatedBounds.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc12_.y = lastCalculatedBounds.y + lastCalculatedBounds.height;
|
||||
}
|
||||
}
|
||||
lastCalculatedBounds = _loc12_;
|
||||
}
|
||||
return _loc12_;
|
||||
}
|
||||
|
||||
override protected function calculateContainerSize(param1:Vector.<ILayoutTarget>) : Point
|
||||
{
|
||||
var _loc2_:BoxAttributesMetadata = null;
|
||||
var _loc6_:Rectangle = null;
|
||||
var _loc5_:Rectangle = null;
|
||||
var _loc7_:Rectangle = null;
|
||||
var _loc3_:Point = new Point(NaN,NaN);
|
||||
var _loc4_:AbsoluteLayoutMetadata = container.layoutMetadata.getValue("http://www.osmf.org/layout/absolute/1.0") as AbsoluteLayoutMetadata;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc3_.x = _loc4_.width;
|
||||
_loc3_.y = _loc4_.height;
|
||||
}
|
||||
if(layoutMode != "none")
|
||||
{
|
||||
_loc2_ = new BoxAttributesMetadata();
|
||||
container.layoutMetadata.addValue("http://www.osmf.org/layout/attributes/box/1.0",_loc2_);
|
||||
}
|
||||
if(isNaN(_loc3_.x) || isNaN(_loc3_.y) || layoutMode != "none")
|
||||
{
|
||||
_loc6_ = new Rectangle();
|
||||
for each(var _loc8_:ILayoutTarget in param1)
|
||||
{
|
||||
if(_loc8_.layoutMetadata.includeInLayout)
|
||||
{
|
||||
_loc5_ = calculateTargetBounds(_loc8_,_loc3_.x,_loc3_.y);
|
||||
_loc5_.x ||= 0;
|
||||
_loc5_.y ||= 0;
|
||||
_loc5_.width ||= _loc8_.measuredWidth || 0;
|
||||
_loc5_.height ||= _loc8_.measuredHeight || 0;
|
||||
if(layoutMode == "horizontal")
|
||||
{
|
||||
if(!isNaN(_loc8_.layoutMetadata.percentWidth))
|
||||
{
|
||||
_loc2_.relativeSum += _loc8_.layoutMetadata.percentWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.absoluteSum += _loc5_.width;
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc5_.x = _loc7_.x + _loc7_.width;
|
||||
}
|
||||
_loc7_ = _loc5_;
|
||||
}
|
||||
else if(layoutMode == "vertical")
|
||||
{
|
||||
if(!isNaN(_loc8_.layoutMetadata.percentHeight))
|
||||
{
|
||||
_loc2_.relativeSum += _loc8_.layoutMetadata.percentHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.absoluteSum += _loc5_.height;
|
||||
}
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc5_.y = _loc7_.y + _loc7_.height;
|
||||
}
|
||||
_loc7_ = _loc5_;
|
||||
}
|
||||
_loc6_ = _loc6_.union(_loc5_);
|
||||
}
|
||||
}
|
||||
_loc3_.x ||= _loc4_ == null || isNaN(_loc4_.width) ? _loc6_.width : _loc4_.width;
|
||||
_loc3_.y ||= _loc4_ == null || isNaN(_loc4_.height) ? _loc6_.height : _loc4_.height;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.metadata.MetadataWatcher;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class LayoutRendererBase extends EventDispatcher
|
||||
{
|
||||
|
||||
private static var cleaningRenderers:Boolean;
|
||||
|
||||
private static var dispatcher:DisplayObject = new Sprite();
|
||||
|
||||
private static var dirtyRenderers:Vector.<LayoutRendererBase> = new Vector.<LayoutRendererBase>();
|
||||
|
||||
private var _parent:LayoutRendererBase;
|
||||
|
||||
private var _container:ILayoutTarget;
|
||||
|
||||
private var layoutMetadata:LayoutMetadata;
|
||||
|
||||
private var layoutTargets:Vector.<ILayoutTarget> = new Vector.<ILayoutTarget>();
|
||||
|
||||
private var stagedDisplayObjects:Dictionary = new Dictionary(true);
|
||||
|
||||
private var _measuredWidth:Number;
|
||||
|
||||
private var _measuredHeight:Number;
|
||||
|
||||
private var dirty:Boolean;
|
||||
|
||||
private var cleaning:Boolean;
|
||||
|
||||
private var metaDataWatchers:Dictionary = new Dictionary();
|
||||
|
||||
public function LayoutRendererBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
private static function flagDirty(param1:LayoutRendererBase) : void
|
||||
{
|
||||
if(param1 == null || dirtyRenderers.indexOf(param1) != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dirtyRenderers.push(param1);
|
||||
if(cleaningRenderers == false)
|
||||
{
|
||||
dispatcher.addEventListener("exitFrame",onExitFrame);
|
||||
}
|
||||
}
|
||||
|
||||
private static function flagClean(param1:LayoutRendererBase) : void
|
||||
{
|
||||
var _loc2_:Number = dirtyRenderers.indexOf(param1);
|
||||
if(_loc2_ != -1)
|
||||
{
|
||||
dirtyRenderers.splice(_loc2_,1);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onExitFrame(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LayoutRendererBase = null;
|
||||
dispatcher.removeEventListener("exitFrame",onExitFrame);
|
||||
cleaningRenderers = true;
|
||||
while(dirtyRenderers.length != 0)
|
||||
{
|
||||
_loc2_ = dirtyRenderers.shift();
|
||||
if(_loc2_.parent == null)
|
||||
{
|
||||
_loc2_.validateNow();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.dirty = false;
|
||||
}
|
||||
}
|
||||
cleaningRenderers = false;
|
||||
}
|
||||
|
||||
final public function get parent() : LayoutRendererBase
|
||||
{
|
||||
return _parent;
|
||||
}
|
||||
|
||||
final internal function setParent(param1:LayoutRendererBase) : void
|
||||
{
|
||||
_parent = param1;
|
||||
processParentChange(_parent);
|
||||
}
|
||||
|
||||
final public function get container() : ILayoutTarget
|
||||
{
|
||||
return _container;
|
||||
}
|
||||
|
||||
final public function set container(param1:ILayoutTarget) : void
|
||||
{
|
||||
var _loc2_:ILayoutTarget = null;
|
||||
if(param1 != _container)
|
||||
{
|
||||
_loc2_ = _container;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
reset();
|
||||
_loc2_.dispatchEvent(new LayoutTargetEvent("unsetAsLayoutRendererContainer",false,false,this));
|
||||
_loc2_.removeEventListener("mediaSizeChange",invalidatingEventHandler);
|
||||
}
|
||||
_container = param1;
|
||||
if(_container)
|
||||
{
|
||||
layoutMetadata = _container.layoutMetadata;
|
||||
_container.addEventListener("mediaSizeChange",invalidatingEventHandler,false,0,true);
|
||||
_container.dispatchEvent(new LayoutTargetEvent("setAsLayoutRendererContainer",false,false,this));
|
||||
invalidate();
|
||||
}
|
||||
processContainerChange(_loc2_,param1);
|
||||
}
|
||||
}
|
||||
|
||||
final public function addTarget(param1:ILayoutTarget) : ILayoutTarget
|
||||
{
|
||||
var _loc2_:MetadataWatcher = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(layoutTargets.indexOf(param1) != -1)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
param1.dispatchEvent(new LayoutTargetEvent("addToLayoutRenderer",false,false,this));
|
||||
var _loc3_:int = Math.abs(BinarySearch.search(layoutTargets,compareTargets,param1));
|
||||
layoutTargets.splice(_loc3_,0,param1);
|
||||
var _loc4_:Array = metaDataWatchers[param1] = [];
|
||||
for each(var _loc5_:String in usedMetadatas)
|
||||
{
|
||||
_loc2_ = new MetadataWatcher(param1.layoutMetadata,_loc5_,null,targetMetadataChangeCallback);
|
||||
_loc2_.watch();
|
||||
_loc4_.push(_loc2_);
|
||||
}
|
||||
param1.addEventListener("displayObjectChange",invalidatingEventHandler);
|
||||
param1.addEventListener("mediaSizeChange",invalidatingEventHandler);
|
||||
param1.addEventListener("addToLayoutRenderer",onTargetAddedToRenderer);
|
||||
param1.addEventListener("setAsLayoutRendererContainer",onTargetSetAsContainer);
|
||||
invalidate();
|
||||
processTargetAdded(param1);
|
||||
return param1;
|
||||
}
|
||||
|
||||
final public function removeTarget(param1:ILayoutTarget) : ILayoutTarget
|
||||
{
|
||||
var _loc4_:ILayoutTarget = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
var _loc3_:Number = layoutTargets.indexOf(param1);
|
||||
if(_loc3_ != -1)
|
||||
{
|
||||
removeFromStage(param1);
|
||||
_loc4_ = layoutTargets.splice(_loc3_,1)[0];
|
||||
param1.removeEventListener("displayObjectChange",invalidatingEventHandler);
|
||||
param1.removeEventListener("mediaSizeChange",invalidatingEventHandler);
|
||||
param1.removeEventListener("addToLayoutRenderer",onTargetAddedToRenderer);
|
||||
param1.removeEventListener("setAsLayoutRendererContainer",onTargetSetAsContainer);
|
||||
for each(var _loc2_:MetadataWatcher in metaDataWatchers[param1])
|
||||
{
|
||||
_loc2_.unwatch();
|
||||
}
|
||||
delete metaDataWatchers[param1];
|
||||
processTargetRemoved(param1);
|
||||
param1.dispatchEvent(new LayoutTargetEvent("removeFromLayoutRenderer",false,false,this));
|
||||
invalidate();
|
||||
return _loc4_;
|
||||
}
|
||||
throw new IllegalOperationError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
|
||||
final public function hasTarget(param1:ILayoutTarget) : Boolean
|
||||
{
|
||||
return layoutTargets.indexOf(param1) != -1;
|
||||
}
|
||||
|
||||
final public function get measuredWidth() : Number
|
||||
{
|
||||
return _measuredWidth;
|
||||
}
|
||||
|
||||
final public function get measuredHeight() : Number
|
||||
{
|
||||
return _measuredHeight;
|
||||
}
|
||||
|
||||
final public function invalidate() : void
|
||||
{
|
||||
if(cleaning == false && dirty == false)
|
||||
{
|
||||
dirty = true;
|
||||
if(_parent != null)
|
||||
{
|
||||
_parent.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
flagDirty(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final public function validateNow() : void
|
||||
{
|
||||
if(_container == null || cleaning == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_parent)
|
||||
{
|
||||
_parent.validateNow();
|
||||
return;
|
||||
}
|
||||
cleaning = true;
|
||||
measure();
|
||||
layout(_measuredWidth,_measuredHeight);
|
||||
cleaning = false;
|
||||
}
|
||||
|
||||
internal function measure() : void
|
||||
{
|
||||
prepareTargets();
|
||||
for each(var _loc2_:ILayoutTarget in layoutTargets)
|
||||
{
|
||||
_loc2_.measure(true);
|
||||
}
|
||||
var _loc1_:Point = calculateContainerSize(layoutTargets);
|
||||
_measuredWidth = _loc1_.x;
|
||||
_measuredHeight = _loc1_.y;
|
||||
_container.measure(false);
|
||||
}
|
||||
|
||||
internal function layout(param1:Number, param2:Number) : void
|
||||
{
|
||||
var _loc4_:Rectangle = null;
|
||||
var _loc3_:DisplayObject = null;
|
||||
processUpdateMediaDisplayBegin(layoutTargets);
|
||||
_container.layout(param1,param2,false);
|
||||
for each(var _loc5_:ILayoutTarget in layoutTargets)
|
||||
{
|
||||
_loc4_ = calculateTargetBounds(_loc5_,param1,param2);
|
||||
_loc5_.layout(_loc4_.width,_loc4_.height,true);
|
||||
_loc3_ = _loc5_.displayObject;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.x = _loc4_.x;
|
||||
_loc3_.y = _loc4_.y;
|
||||
}
|
||||
}
|
||||
dirty = false;
|
||||
processUpdateMediaDisplayEnd();
|
||||
}
|
||||
|
||||
protected function get usedMetadatas() : Vector.<String>
|
||||
{
|
||||
return new Vector.<String>();
|
||||
}
|
||||
|
||||
protected function compareTargets(param1:ILayoutTarget, param2:ILayoutTarget) : Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processContainerChange(param1:ILayoutTarget, param2:ILayoutTarget) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processTargetAdded(param1:ILayoutTarget) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processTargetRemoved(param1:ILayoutTarget) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processStagedTarget(param1:ILayoutTarget) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processUnstagedTarget(param1:ILayoutTarget) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processUpdateMediaDisplayBegin(param1:Vector.<ILayoutTarget>) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processUpdateMediaDisplayEnd() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function updateTargetOrder(param1:ILayoutTarget) : void
|
||||
{
|
||||
var _loc2_:int = layoutTargets.indexOf(param1);
|
||||
if(_loc2_ != -1)
|
||||
{
|
||||
layoutTargets.splice(_loc2_,1);
|
||||
_loc2_ = Math.abs(BinarySearch.search(layoutTargets,compareTargets,param1));
|
||||
layoutTargets.splice(_loc2_,0,param1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function calculateTargetBounds(param1:ILayoutTarget, param2:Number, param3:Number) : Rectangle
|
||||
{
|
||||
return new Rectangle();
|
||||
}
|
||||
|
||||
protected function calculateContainerSize(param1:Vector.<ILayoutTarget>) : Point
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
protected function processParentChange(param1:LayoutRendererBase) : void
|
||||
{
|
||||
}
|
||||
|
||||
private function reset() : void
|
||||
{
|
||||
for each(var _loc1_:ILayoutTarget in layoutTargets)
|
||||
{
|
||||
removeTarget(_loc1_);
|
||||
}
|
||||
if(_container)
|
||||
{
|
||||
_container.removeEventListener("mediaSizeChange",invalidatingEventHandler);
|
||||
validateNow();
|
||||
}
|
||||
_container = null;
|
||||
layoutMetadata = null;
|
||||
}
|
||||
|
||||
private function targetMetadataChangeCallback(param1:Metadata) : void
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private function invalidatingEventHandler(param1:Event) : void
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private function onTargetAddedToRenderer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
var _loc2_:ILayoutTarget = null;
|
||||
if(param1.layoutRenderer != this)
|
||||
{
|
||||
_loc2_ = param1.target as ILayoutTarget;
|
||||
if(hasTarget(_loc2_))
|
||||
{
|
||||
removeTarget(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onTargetSetAsContainer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
var _loc2_:ILayoutTarget = null;
|
||||
if(param1.layoutRenderer != this)
|
||||
{
|
||||
_loc2_ = param1.target as ILayoutTarget;
|
||||
if(container == _loc2_)
|
||||
{
|
||||
container = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareTargets() : void
|
||||
{
|
||||
var _loc1_:DisplayObject = null;
|
||||
var _loc2_:int = 0;
|
||||
for each(var _loc3_:ILayoutTarget in layoutTargets)
|
||||
{
|
||||
_loc1_ = _loc3_.displayObject;
|
||||
if(_loc1_)
|
||||
{
|
||||
addToStage(_loc3_,_loc3_.displayObject,_loc2_);
|
||||
_loc2_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
removeFromStage(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addToStage(param1:ILayoutTarget, param2:DisplayObject, param3:Number) : void
|
||||
{
|
||||
var _loc4_:DisplayObject = stagedDisplayObjects[param1];
|
||||
if(_loc4_ == param2)
|
||||
{
|
||||
_container.dispatchEvent(new LayoutTargetEvent("setChildIndex",false,false,this,param1,_loc4_,param3));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_container.dispatchEvent(new LayoutTargetEvent("removeChild",false,false,this,param1,_loc4_));
|
||||
}
|
||||
stagedDisplayObjects[param1] = param2;
|
||||
_container.dispatchEvent(new LayoutTargetEvent("addChildAt",false,false,this,param1,param2,param3));
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
processStagedTarget(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function removeFromStage(param1:ILayoutTarget) : void
|
||||
{
|
||||
var _loc2_:DisplayObject = stagedDisplayObjects[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
delete stagedDisplayObjects[param1];
|
||||
_container.dispatchEvent(new LayoutTargetEvent("removeChild",false,false,this,param1,_loc2_));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
|
||||
public class LayoutTargetEvent extends Event
|
||||
{
|
||||
|
||||
public static const SET_AS_LAYOUT_RENDERER_CONTAINER:String = "setAsLayoutRendererContainer";
|
||||
|
||||
public static const UNSET_AS_LAYOUT_RENDERER_CONTAINER:String = "unsetAsLayoutRendererContainer";
|
||||
|
||||
public static const ADD_TO_LAYOUT_RENDERER:String = "addToLayoutRenderer";
|
||||
|
||||
public static const REMOVE_FROM_LAYOUT_RENDERER:String = "removeFromLayoutRenderer";
|
||||
|
||||
public static const ADD_CHILD_AT:String = "addChildAt";
|
||||
|
||||
public static const REMOVE_CHILD:String = "removeChild";
|
||||
|
||||
public static const SET_CHILD_INDEX:String = "setChildIndex";
|
||||
|
||||
private var _layoutRenderer:LayoutRendererBase;
|
||||
|
||||
private var _layoutTarget:ILayoutTarget;
|
||||
|
||||
private var _displayObject:DisplayObject;
|
||||
|
||||
private var _index:int;
|
||||
|
||||
public function LayoutTargetEvent(param1:String, param2:Boolean = false, param3:Boolean = false, param4:LayoutRendererBase = null, param5:ILayoutTarget = null, param6:DisplayObject = null, param7:int = -1)
|
||||
{
|
||||
_layoutRenderer = param4;
|
||||
_layoutTarget = param5;
|
||||
_displayObject = param6;
|
||||
_index = param7;
|
||||
super(param1,param2,param3);
|
||||
}
|
||||
|
||||
public function get layoutRenderer() : LayoutRendererBase
|
||||
{
|
||||
return _layoutRenderer;
|
||||
}
|
||||
|
||||
public function get layoutTarget() : ILayoutTarget
|
||||
{
|
||||
return _layoutTarget;
|
||||
}
|
||||
|
||||
public function get displayObject() : DisplayObject
|
||||
{
|
||||
return _displayObject;
|
||||
}
|
||||
|
||||
public function get index() : int
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new LayoutTargetEvent(type,bubbles,cancelable,_layoutRenderer,_layoutTarget,_displayObject,_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
internal class LayoutTargetRenderers
|
||||
{
|
||||
|
||||
public var containerRenderer:LayoutRendererBase;
|
||||
|
||||
public var parentRenderer:LayoutRendererBase;
|
||||
|
||||
public function LayoutTargetRenderers(param1:ILayoutTarget)
|
||||
{
|
||||
super();
|
||||
param1.addEventListener("addToLayoutRenderer",onAddedToLayoutRenderer);
|
||||
param1.addEventListener("removeFromLayoutRenderer",onRemovedFromLayoutRenderer);
|
||||
param1.addEventListener("setAsLayoutRendererContainer",onSetAsLayoutRendererContainer);
|
||||
param1.addEventListener("unsetAsLayoutRendererContainer",onUnsetAsLayoutRendererContainer);
|
||||
}
|
||||
|
||||
private function onSetAsLayoutRendererContainer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(containerRenderer != param1.layoutRenderer)
|
||||
{
|
||||
containerRenderer = param1.layoutRenderer;
|
||||
containerRenderer.setParent(parentRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
private function onUnsetAsLayoutRendererContainer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(containerRenderer != null && containerRenderer == param1.layoutRenderer)
|
||||
{
|
||||
containerRenderer.setParent(null);
|
||||
containerRenderer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onAddedToLayoutRenderer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(parentRenderer != param1.layoutRenderer)
|
||||
{
|
||||
parentRenderer = param1.layoutRenderer;
|
||||
if(containerRenderer)
|
||||
{
|
||||
containerRenderer.setParent(parentRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onRemovedFromLayoutRenderer(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(parentRenderer == param1.layoutRenderer)
|
||||
{
|
||||
parentRenderer = null;
|
||||
if(containerRenderer)
|
||||
{
|
||||
containerRenderer.setParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import org.osmf.events.DisplayObjectEvent;
|
||||
|
||||
public class LayoutTargetSprite extends Sprite implements ILayoutTarget
|
||||
{
|
||||
|
||||
private var _layoutMetadata:LayoutMetadata;
|
||||
|
||||
private var _measuredWidth:Number = NaN;
|
||||
|
||||
private var _measuredHeight:Number = NaN;
|
||||
|
||||
private var renderers:LayoutTargetRenderers = new LayoutTargetRenderers(this);
|
||||
|
||||
public function LayoutTargetSprite(param1:LayoutMetadata = null)
|
||||
{
|
||||
_layoutMetadata = param1 || new LayoutMetadata();
|
||||
addEventListener("addChildAt",onAddChildAt);
|
||||
addEventListener("setChildIndex",onSetChildIndex);
|
||||
addEventListener("removeChild",onRemoveChild);
|
||||
mouseEnabled = true;
|
||||
mouseChildren = true;
|
||||
super();
|
||||
}
|
||||
|
||||
public function get displayObject() : DisplayObject
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public function get layoutMetadata() : LayoutMetadata
|
||||
{
|
||||
return _layoutMetadata;
|
||||
}
|
||||
|
||||
public function get measuredWidth() : Number
|
||||
{
|
||||
return _measuredWidth;
|
||||
}
|
||||
|
||||
public function get measuredHeight() : Number
|
||||
{
|
||||
return _measuredHeight;
|
||||
}
|
||||
|
||||
public function measure(param1:Boolean = true) : void
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:DisplayObjectEvent = null;
|
||||
if(param1 && renderers.containerRenderer)
|
||||
{
|
||||
renderers.containerRenderer.measure();
|
||||
}
|
||||
if(renderers.containerRenderer)
|
||||
{
|
||||
_loc4_ = renderers.containerRenderer.measuredWidth;
|
||||
_loc2_ = renderers.containerRenderer.measuredHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = super.width / scaleX;
|
||||
_loc2_ = super.height / scaleY;
|
||||
}
|
||||
if(_loc4_ != _measuredWidth || _loc2_ != _measuredHeight)
|
||||
{
|
||||
_loc3_ = new DisplayObjectEvent("mediaSizeChange",false,false,null,null,_measuredWidth,_measuredHeight,_loc4_,_loc2_);
|
||||
_measuredWidth = _loc4_;
|
||||
_measuredHeight = _loc2_;
|
||||
dispatchEvent(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
public function layout(param1:Number, param2:Number, param3:Boolean = true) : void
|
||||
{
|
||||
if(renderers.containerRenderer == null)
|
||||
{
|
||||
super.width = param1;
|
||||
super.height = param2;
|
||||
}
|
||||
else if(param3)
|
||||
{
|
||||
renderers.containerRenderer.layout(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateNow() : void
|
||||
{
|
||||
if(renderers.containerRenderer)
|
||||
{
|
||||
renderers.containerRenderer.validateNow();
|
||||
}
|
||||
}
|
||||
|
||||
protected function onAddChildAt(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
addChildAt(param1.displayObject,param1.index);
|
||||
}
|
||||
|
||||
protected function onRemoveChild(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
removeChild(param1.displayObject);
|
||||
}
|
||||
|
||||
protected function onSetChildIndex(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
setChildIndex(param1.displayObject,param1.index);
|
||||
}
|
||||
|
||||
override public function set width(param1:Number) : void
|
||||
{
|
||||
_layoutMetadata.width = param1;
|
||||
}
|
||||
|
||||
override public function get width() : Number
|
||||
{
|
||||
return _measuredWidth;
|
||||
}
|
||||
|
||||
override public function set height(param1:Number) : void
|
||||
{
|
||||
_layoutMetadata.height = param1;
|
||||
}
|
||||
|
||||
override public function get height() : Number
|
||||
{
|
||||
return _measuredHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.events.DisplayObjectEvent;
|
||||
import org.osmf.events.MediaElementEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
import org.osmf.traits.DisplayObjectTrait;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaElementLayoutTarget extends EventDispatcher implements ILayoutTarget
|
||||
{
|
||||
|
||||
private static const layoutTargets:Dictionary = new Dictionary(true);
|
||||
|
||||
private var _mediaElement:MediaElement;
|
||||
|
||||
private var _layoutMetadata:LayoutMetadata;
|
||||
|
||||
private var displayObjectTrait:DisplayObjectTrait;
|
||||
|
||||
private var _displayObject:DisplayObject;
|
||||
|
||||
private var renderers:LayoutTargetRenderers;
|
||||
|
||||
public function MediaElementLayoutTarget(param1:MediaElement, param2:Class)
|
||||
{
|
||||
super();
|
||||
if(param2 != ConstructorLock)
|
||||
{
|
||||
throw new IllegalOperationError(OSMFStrings.getString("illegalConstructorInvocation"));
|
||||
}
|
||||
_mediaElement = param1;
|
||||
_mediaElement.addEventListener("traitAdd",onMediaElementTraitsChange);
|
||||
_mediaElement.addEventListener("traitRemove",onMediaElementTraitsChange);
|
||||
_mediaElement.addEventListener("metadataAdd",onMetadataAdd);
|
||||
_mediaElement.addEventListener("metadataRemove",onMetadataRemove);
|
||||
renderers = new LayoutTargetRenderers(this);
|
||||
_layoutMetadata = _mediaElement.getMetadata("http://www.osmf.org/layout/1.0") as LayoutMetadata;
|
||||
addEventListener("addChildAt",onAddChildAt);
|
||||
addEventListener("setChildIndex",onSetChildIndex);
|
||||
addEventListener("removeChild",onRemoveChild);
|
||||
onMediaElementTraitsChange();
|
||||
}
|
||||
|
||||
public static function getInstance(param1:MediaElement) : MediaElementLayoutTarget
|
||||
{
|
||||
var _loc2_:* = undefined;
|
||||
for(_loc2_ in layoutTargets)
|
||||
{
|
||||
if(_loc2_.mediaElement == param1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_ = null;
|
||||
}
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
_loc2_ = new MediaElementLayoutTarget(param1,ConstructorLock);
|
||||
layoutTargets[_loc2_] = true;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function get mediaElement() : MediaElement
|
||||
{
|
||||
return _mediaElement;
|
||||
}
|
||||
|
||||
public function get layoutMetadata() : LayoutMetadata
|
||||
{
|
||||
if(_layoutMetadata == null)
|
||||
{
|
||||
_layoutMetadata = new LayoutMetadata();
|
||||
_mediaElement.addMetadata("http://www.osmf.org/layout/1.0",_layoutMetadata);
|
||||
}
|
||||
return _layoutMetadata;
|
||||
}
|
||||
|
||||
public function get displayObject() : DisplayObject
|
||||
{
|
||||
return _displayObject;
|
||||
}
|
||||
|
||||
public function get measuredWidth() : Number
|
||||
{
|
||||
return displayObjectTrait ? displayObjectTrait.mediaWidth : NaN;
|
||||
}
|
||||
|
||||
public function get measuredHeight() : Number
|
||||
{
|
||||
return displayObjectTrait ? displayObjectTrait.mediaHeight : NaN;
|
||||
}
|
||||
|
||||
public function measure(param1:Boolean = true) : void
|
||||
{
|
||||
if(_displayObject is ILayoutTarget)
|
||||
{
|
||||
ILayoutTarget(_displayObject).measure(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function layout(param1:Number, param2:Number, param3:Boolean = true) : void
|
||||
{
|
||||
if(_displayObject is ILayoutTarget)
|
||||
{
|
||||
ILayoutTarget(_displayObject).layout(param1,param2,param3);
|
||||
}
|
||||
else if(_displayObject != null && renderers.containerRenderer == null)
|
||||
{
|
||||
_displayObject.width = param1;
|
||||
_displayObject.height = param2;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaElementTraitsChange(param1:MediaElementEvent = null) : void
|
||||
{
|
||||
var _loc2_:DisplayObjectTrait = null;
|
||||
if(param1 == null || param1 && param1.traitType == "displayObject")
|
||||
{
|
||||
_loc2_ = param1 && param1.type == "traitRemove" ? null : _mediaElement.getTrait("displayObject") as DisplayObjectTrait;
|
||||
if(_loc2_ != displayObjectTrait)
|
||||
{
|
||||
if(displayObjectTrait)
|
||||
{
|
||||
displayObjectTrait.removeEventListener("displayObjectChange",onDisplayObjectTraitDisplayObjecChange);
|
||||
displayObjectTrait.removeEventListener("mediaSizeChange",onDisplayObjectTraitMediaSizeChange);
|
||||
}
|
||||
displayObjectTrait = _loc2_;
|
||||
if(displayObjectTrait)
|
||||
{
|
||||
displayObjectTrait.addEventListener("displayObjectChange",onDisplayObjectTraitDisplayObjecChange);
|
||||
displayObjectTrait.addEventListener("mediaSizeChange",onDisplayObjectTraitMediaSizeChange);
|
||||
}
|
||||
updateDisplayObject(displayObjectTrait ? displayObjectTrait.displayObject : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetadataAdd(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(param1.namespaceURL == "http://www.osmf.org/layout/1.0")
|
||||
{
|
||||
_layoutMetadata = param1.metadata as LayoutMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetadataRemove(param1:MediaElementEvent) : void
|
||||
{
|
||||
if(param1.namespaceURL == "http://www.osmf.org/layout/1.0")
|
||||
{
|
||||
_layoutMetadata = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function updateDisplayObject(param1:DisplayObject) : void
|
||||
{
|
||||
var _loc2_:DisplayObject = _displayObject;
|
||||
if(param1 != displayObject)
|
||||
{
|
||||
_displayObject = param1;
|
||||
dispatchEvent(new DisplayObjectEvent("displayObjectChange",false,false,_loc2_,param1));
|
||||
}
|
||||
if(param1 is ILayoutTarget && renderers.parentRenderer)
|
||||
{
|
||||
ILayoutTarget(param1).dispatchEvent(new LayoutTargetEvent("addToLayoutRenderer",false,false,renderers.parentRenderer));
|
||||
}
|
||||
}
|
||||
|
||||
private function onDisplayObjectTraitDisplayObjecChange(param1:DisplayObjectEvent) : void
|
||||
{
|
||||
updateDisplayObject(param1.newDisplayObject);
|
||||
}
|
||||
|
||||
private function onDisplayObjectTraitMediaSizeChange(param1:DisplayObjectEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onAddChildAt(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(_displayObject is ILayoutTarget)
|
||||
{
|
||||
ILayoutTarget(_displayObject).dispatchEvent(param1.clone());
|
||||
}
|
||||
else if(_displayObject is DisplayObjectContainer)
|
||||
{
|
||||
DisplayObjectContainer(_displayObject).addChildAt(param1.displayObject,param1.index);
|
||||
}
|
||||
}
|
||||
|
||||
private function onRemoveChild(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(_displayObject is ILayoutTarget)
|
||||
{
|
||||
ILayoutTarget(_displayObject).dispatchEvent(param1.clone());
|
||||
}
|
||||
else if(_displayObject is DisplayObjectContainer)
|
||||
{
|
||||
DisplayObjectContainer(_displayObject).removeChild(param1.displayObject);
|
||||
}
|
||||
}
|
||||
|
||||
private function onSetChildIndex(param1:LayoutTargetEvent) : void
|
||||
{
|
||||
if(_displayObject is ILayoutTarget)
|
||||
{
|
||||
ILayoutTarget(_displayObject).dispatchEvent(param1.clone());
|
||||
}
|
||||
else if(_displayObject is DisplayObjectContainer)
|
||||
{
|
||||
DisplayObjectContainer(_displayObject).setChildIndex(param1.displayObject,param1.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ConstructorLock
|
||||
{
|
||||
|
||||
public function ConstructorLock()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class PaddingLayoutMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const LEFT:String = "left";
|
||||
|
||||
public static const TOP:String = "top";
|
||||
|
||||
public static const RIGHT:String = "right";
|
||||
|
||||
public static const BOTTOM:String = "bottom";
|
||||
|
||||
private var _left:Number;
|
||||
|
||||
private var _top:Number;
|
||||
|
||||
private var _right:Number;
|
||||
|
||||
private var _bottom:Number;
|
||||
|
||||
public function PaddingLayoutMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "left")
|
||||
{
|
||||
return left;
|
||||
}
|
||||
if(param1 == "top")
|
||||
{
|
||||
return top;
|
||||
}
|
||||
if(param1 == "right")
|
||||
{
|
||||
return right;
|
||||
}
|
||||
if(param1 == "bottom")
|
||||
{
|
||||
return bottom;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get left() : Number
|
||||
{
|
||||
return _left;
|
||||
}
|
||||
|
||||
public function set left(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_left != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"left",param1,_left);
|
||||
_left = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get top() : Number
|
||||
{
|
||||
return _top;
|
||||
}
|
||||
|
||||
public function set top(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_top != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"top",param1,_top);
|
||||
_top = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get right() : Number
|
||||
{
|
||||
return _right;
|
||||
}
|
||||
|
||||
public function set right(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_right != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"right",param1,_right);
|
||||
_right = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get bottom() : Number
|
||||
{
|
||||
return _bottom;
|
||||
}
|
||||
|
||||
public function set bottom(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_bottom != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"bottom",param1,_bottom);
|
||||
_bottom = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.NonSynthesizingMetadata;
|
||||
|
||||
internal class RelativeLayoutMetadata extends NonSynthesizingMetadata
|
||||
{
|
||||
|
||||
public static const X:String = "x";
|
||||
|
||||
public static const Y:String = "y";
|
||||
|
||||
public static const WIDTH:String = "width";
|
||||
|
||||
public static const HEIGHT:String = "height";
|
||||
|
||||
private var _x:Number;
|
||||
|
||||
private var _y:Number;
|
||||
|
||||
private var _width:Number;
|
||||
|
||||
private var _height:Number;
|
||||
|
||||
public function RelativeLayoutMetadata()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function getValue(param1:String) : *
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
if(param1 == "x")
|
||||
{
|
||||
return x;
|
||||
}
|
||||
if(param1 == "y")
|
||||
{
|
||||
return y;
|
||||
}
|
||||
if(param1 == "width")
|
||||
{
|
||||
return width;
|
||||
}
|
||||
if(param1 == "height")
|
||||
{
|
||||
return height;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public function get x() : Number
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
public function set x(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_x != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"x",param1,_x);
|
||||
_x = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get y() : Number
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
public function set y(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_y != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"y",param1,_y);
|
||||
_y = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get width() : Number
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
public function set width(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_width != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"width",param1,_width);
|
||||
_width = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function get height() : Number
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
public function set height(param1:Number) : void
|
||||
{
|
||||
var _loc2_:MetadataEvent = null;
|
||||
if(_height != param1)
|
||||
{
|
||||
_loc2_ = new MetadataEvent("valueChange",false,false,"height",param1,_height);
|
||||
_height = param1;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
public final class ScaleMode
|
||||
{
|
||||
|
||||
public static const NONE:String = "none";
|
||||
|
||||
public static const STRETCH:String = "stretch";
|
||||
|
||||
public static const LETTERBOX:String = "letterbox";
|
||||
|
||||
public static const ZOOM:String = "zoom";
|
||||
|
||||
public function ScaleMode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.geom.Point;
|
||||
|
||||
internal class ScaleModeUtils
|
||||
{
|
||||
|
||||
public function ScaleModeUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getScaledSize(param1:String, param2:Number, param3:Number, param4:Number, param5:Number) : Point
|
||||
{
|
||||
var _loc6_:Point = null;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
switch(param1)
|
||||
{
|
||||
case "zoom":
|
||||
case "letterbox":
|
||||
_loc8_ = param2 / param3;
|
||||
_loc7_ = (param4 || param2) / (param5 || param3);
|
||||
if(param1 == "zoom" && _loc7_ < _loc8_ || param1 == "letterbox" && _loc7_ > _loc8_)
|
||||
{
|
||||
_loc6_ = new Point(param2,param2 / _loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new Point(param3 * _loc7_,param3);
|
||||
}
|
||||
break;
|
||||
case "stretch":
|
||||
_loc6_ = new Point(param2,param3);
|
||||
break;
|
||||
case "none":
|
||||
_loc6_ = new Point(param4 || param2,param5 || param3);
|
||||
}
|
||||
return _loc6_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
public final class VerticalAlign
|
||||
{
|
||||
|
||||
public static const TOP:String = "top";
|
||||
|
||||
public static const MIDDLE:String = "middle";
|
||||
|
||||
public static const BOTTOM:String = "bottom";
|
||||
|
||||
public function VerticalAlign()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.elements.AudioElement;
|
||||
import org.osmf.elements.F4MElement;
|
||||
import org.osmf.elements.F4MLoader;
|
||||
import org.osmf.elements.ImageElement;
|
||||
import org.osmf.elements.ImageLoader;
|
||||
import org.osmf.elements.SWFElement;
|
||||
import org.osmf.elements.SWFLoader;
|
||||
import org.osmf.elements.SoundLoader;
|
||||
import org.osmf.elements.VideoElement;
|
||||
import org.osmf.net.MulticastNetLoader;
|
||||
import org.osmf.net.NetLoader;
|
||||
import org.osmf.net.dvr.DVRCastNetLoader;
|
||||
import org.osmf.net.httpstreaming.HTTPStreamingNetLoader;
|
||||
import org.osmf.net.rtmpstreaming.RTMPDynamicStreamingNetLoader;
|
||||
|
||||
public class DefaultMediaFactory extends MediaFactory
|
||||
{
|
||||
|
||||
private var rtmpStreamingNetLoader:RTMPDynamicStreamingNetLoader;
|
||||
|
||||
private var f4mLoader:F4MLoader;
|
||||
|
||||
private var dvrCastLoader:DVRCastNetLoader;
|
||||
|
||||
private var netLoader:NetLoader;
|
||||
|
||||
private var imageLoader:ImageLoader;
|
||||
|
||||
private var swfLoader:SWFLoader;
|
||||
|
||||
private var soundLoader:SoundLoader;
|
||||
|
||||
private var httpStreamingNetLoader:HTTPStreamingNetLoader;
|
||||
|
||||
private var multicastLoader:MulticastNetLoader;
|
||||
|
||||
public function DefaultMediaFactory()
|
||||
{
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
f4mLoader = new F4MLoader(this);
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.f4m",f4mLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new F4MElement(null,f4mLoader);
|
||||
}));
|
||||
dvrCastLoader = new DVRCastNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.dvr.dvrcast",dvrCastLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,dvrCastLoader);
|
||||
}));
|
||||
httpStreamingNetLoader = new HTTPStreamingNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.httpstreaming",httpStreamingNetLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,httpStreamingNetLoader);
|
||||
}));
|
||||
multicastLoader = new MulticastNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.rtmfp.multicast",multicastLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,multicastLoader);
|
||||
}));
|
||||
rtmpStreamingNetLoader = new RTMPDynamicStreamingNetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video.rtmpdynamicStreaming",rtmpStreamingNetLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,rtmpStreamingNetLoader);
|
||||
}));
|
||||
netLoader = new NetLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.video",netLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new VideoElement(null,netLoader);
|
||||
}));
|
||||
soundLoader = new SoundLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.audio",soundLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new AudioElement(null,soundLoader);
|
||||
}));
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.audio.streaming",netLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new AudioElement(null,netLoader);
|
||||
}));
|
||||
imageLoader = new ImageLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.image",imageLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new ImageElement(null,imageLoader);
|
||||
}));
|
||||
swfLoader = new SWFLoader();
|
||||
addItem(new MediaFactoryItem("org.osmf.elements.swf",swfLoader.canHandleResource,function():MediaElement
|
||||
{
|
||||
return new SWFElement(null,swfLoader);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class DefaultTraitResolver extends MediaTraitResolver
|
||||
{
|
||||
|
||||
private var defaultTrait:MediaTraitBase;
|
||||
|
||||
private var trait:MediaTraitBase;
|
||||
|
||||
public function DefaultTraitResolver(param1:String, param2:MediaTraitBase)
|
||||
{
|
||||
super(param1);
|
||||
if(param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param2.traitType != param1)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
this.defaultTrait = param2;
|
||||
setResolvedTrait(param2);
|
||||
}
|
||||
|
||||
override protected function processAddTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(trait == null)
|
||||
{
|
||||
setResolvedTrait(trait = param1);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function processRemoveTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
var _loc2_:MediaTraitBase = null;
|
||||
if(param1 && param1 == trait)
|
||||
{
|
||||
_loc2_ = trait;
|
||||
trait = null;
|
||||
setResolvedTrait(defaultTrait);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class LoadableElementBase extends MediaElement
|
||||
{
|
||||
|
||||
private var _loader:LoaderBase;
|
||||
|
||||
public function LoadableElementBase(param1:MediaResourceBase = null, param2:LoaderBase = null)
|
||||
{
|
||||
super();
|
||||
_loader = param2;
|
||||
this.resource = param1;
|
||||
}
|
||||
|
||||
override public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
super.resource = param1;
|
||||
updateLoadTrait();
|
||||
}
|
||||
|
||||
final protected function get loader() : LoaderBase
|
||||
{
|
||||
return _loader;
|
||||
}
|
||||
|
||||
final protected function set loader(param1:LoaderBase) : void
|
||||
{
|
||||
_loader = param1;
|
||||
}
|
||||
|
||||
protected function createLoadTrait(param1:MediaResourceBase, param2:LoaderBase) : LoadTrait
|
||||
{
|
||||
return new LoadTrait(_loader,param1);
|
||||
}
|
||||
|
||||
protected function processLoadingState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processReadyState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processUnloadingState() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function getLoaderForResource(param1:MediaResourceBase, param2:Vector.<LoaderBase>) : LoaderBase
|
||||
{
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc3_:LoaderBase = loader;
|
||||
if(param1 != null && (loader == null || loader.canHandleResource(param1) == false))
|
||||
{
|
||||
_loc5_ = false;
|
||||
for each(var _loc4_:LoaderBase in param2)
|
||||
{
|
||||
if(loader == null || loader != _loc4_)
|
||||
{
|
||||
if(_loc4_.canHandleResource(param1))
|
||||
{
|
||||
_loc3_ = _loc4_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc3_ == null && param2 != null)
|
||||
{
|
||||
_loc3_ = param2[param2.length - 1];
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function onLoadStateChange(param1:LoadEvent) : void
|
||||
{
|
||||
if(param1.loadState == "loading")
|
||||
{
|
||||
processLoadingState();
|
||||
}
|
||||
else if(param1.loadState == "ready")
|
||||
{
|
||||
processReadyState();
|
||||
}
|
||||
else if(param1.loadState == "unloading")
|
||||
{
|
||||
processUnloadingState();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateLoadTrait() : void
|
||||
{
|
||||
var _loc1_:LoadTrait = getTrait("load") as LoadTrait;
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
if(_loc1_.loadState == "ready")
|
||||
{
|
||||
_loc1_.unload();
|
||||
}
|
||||
_loc1_.removeEventListener("loadStateChange",onLoadStateChange);
|
||||
removeTrait("load");
|
||||
}
|
||||
if(loader != null)
|
||||
{
|
||||
_loc1_ = createLoadTrait(resource,loader);
|
||||
_loc1_.addEventListener("loadStateChange",onLoadStateChange,false,10);
|
||||
addTrait("load",_loc1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.containers.IMediaContainer;
|
||||
import org.osmf.events.ContainerChangeEvent;
|
||||
import org.osmf.events.MediaElementEvent;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.events.MetadataEvent;
|
||||
import org.osmf.metadata.Metadata;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaElement extends EventDispatcher
|
||||
{
|
||||
|
||||
private var traits:Dictionary = new Dictionary();
|
||||
|
||||
private var traitResolvers:Dictionary = new Dictionary();
|
||||
|
||||
private var unresolvedTraits:Dictionary = new Dictionary();
|
||||
|
||||
private var _traitTypes:Vector.<String> = new Vector.<String>();
|
||||
|
||||
private var _resource:MediaResourceBase;
|
||||
|
||||
private var _metadata:Metadata;
|
||||
|
||||
private var _container:IMediaContainer;
|
||||
|
||||
public function MediaElement()
|
||||
{
|
||||
super();
|
||||
_metadata = createMetadata();
|
||||
_metadata.addEventListener("valueAdd",onMetadataValueAdd);
|
||||
_metadata.addEventListener("valueRemove",onMetadataValueRemove);
|
||||
_metadata.addEventListener("valueChange",onMetadataValueChange);
|
||||
setupTraitResolvers();
|
||||
setupTraits();
|
||||
addEventListener("containerChange",onContainerChange,false,1.7976931348623157e+308);
|
||||
}
|
||||
|
||||
public function get traitTypes() : Vector.<String>
|
||||
{
|
||||
return _traitTypes.concat();
|
||||
}
|
||||
|
||||
public function hasTrait(param1:String) : Boolean
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return traits[param1] != null;
|
||||
}
|
||||
|
||||
public function getTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return traits[param1];
|
||||
}
|
||||
|
||||
public function get resource() : MediaResourceBase
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public function set resource(param1:MediaResourceBase) : void
|
||||
{
|
||||
_resource = param1;
|
||||
}
|
||||
|
||||
public function get container() : IMediaContainer
|
||||
{
|
||||
return _container;
|
||||
}
|
||||
|
||||
public function addMetadata(param1:String, param2:Metadata) : void
|
||||
{
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
this.metadata.addValue(param1,param2);
|
||||
}
|
||||
|
||||
public function removeMetadata(param1:String) : Metadata
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
return metadata.removeValue(param1) as Metadata;
|
||||
}
|
||||
|
||||
public function getMetadata(param1:String) : Metadata
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
return metadata.getValue(param1) as Metadata;
|
||||
}
|
||||
|
||||
public function get metadataNamespaceURLs() : Vector.<String>
|
||||
{
|
||||
return metadata.keys;
|
||||
}
|
||||
|
||||
protected function createMetadata() : Metadata
|
||||
{
|
||||
return new Metadata();
|
||||
}
|
||||
|
||||
public function get metadata() : Metadata
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
protected function addTrait(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 == null || param2 == null || param1 != param2.traitType)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc3_:MediaTraitResolver = traitResolvers[param1];
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.addTrait(param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalTrait(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeTrait(param1:String) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc3_:MediaTraitBase = traits[param1];
|
||||
var _loc2_:MediaTraitResolver = traitResolvers[param1];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
return _loc2_.removeTrait(_loc3_);
|
||||
}
|
||||
return setLocalTrait(param1,null);
|
||||
}
|
||||
|
||||
final protected function addTraitResolver(param1:String, param2:MediaTraitResolver) : void
|
||||
{
|
||||
var _loc3_:MediaTraitBase = null;
|
||||
if(param2 == null || param2.type != param1)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
if(traitResolvers[param1] == null)
|
||||
{
|
||||
unresolvedTraits[param1] = traits[param1];
|
||||
traitResolvers[param1] = param2;
|
||||
_loc3_ = traits[param1];
|
||||
if(_loc3_)
|
||||
{
|
||||
param2.addTrait(_loc3_);
|
||||
}
|
||||
processResolvedTraitChange(param1,param2.resolvedTrait);
|
||||
param2.addEventListener("change",onTraitResolverChange);
|
||||
return;
|
||||
}
|
||||
throw new ArgumentError(OSMFStrings.getString("traitResolverAlreadyAdded"));
|
||||
}
|
||||
|
||||
final protected function removeTraitResolver(param1:String) : MediaTraitResolver
|
||||
{
|
||||
if(param1 == null || traitResolvers[param1] == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:MediaTraitResolver = traitResolvers[param1];
|
||||
_loc2_.removeEventListener("change",onTraitResolverChange);
|
||||
delete traitResolvers[param1];
|
||||
var _loc3_:MediaTraitBase = unresolvedTraits[param1];
|
||||
if(_loc3_ != traits[param1])
|
||||
{
|
||||
setLocalTrait(param1,_loc3_);
|
||||
}
|
||||
delete unresolvedTraits[param1];
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
final protected function getTraitResolver(param1:String) : MediaTraitResolver
|
||||
{
|
||||
return traitResolvers[param1];
|
||||
}
|
||||
|
||||
protected function setupTraitResolvers() : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function setupTraits() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function onMediaError(param1:MediaErrorEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function setLocalTrait(param1:String, param2:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
var _loc3_:MediaTraitBase = traits[param1];
|
||||
if(param2 == null)
|
||||
{
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.removeEventListener("mediaError",onMediaError);
|
||||
_loc3_.dispose();
|
||||
dispatchEvent(new MediaElementEvent("traitRemove",false,false,param1));
|
||||
_traitTypes.splice(_traitTypes.indexOf(param1),1);
|
||||
delete traits[param1];
|
||||
}
|
||||
}
|
||||
else if(_loc3_ == null)
|
||||
{
|
||||
traits[param1] = _loc3_ = param2;
|
||||
_traitTypes.push(param1);
|
||||
_loc3_.addEventListener("mediaError",onMediaError);
|
||||
dispatchEvent(new MediaElementEvent("traitAdd",false,false,param1));
|
||||
}
|
||||
else if(_loc3_ != param2)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("traitInstanceAlreadyAdded"));
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
private function onTraitResolverChange(param1:Event) : void
|
||||
{
|
||||
var _loc2_:MediaTraitResolver = param1.target as MediaTraitResolver;
|
||||
processResolvedTraitChange(_loc2_.type,_loc2_.resolvedTrait);
|
||||
}
|
||||
|
||||
private function processResolvedTraitChange(param1:String, param2:MediaTraitBase) : void
|
||||
{
|
||||
if(param2 != traits[param1])
|
||||
{
|
||||
setLocalTrait(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
private function onContainerChange(param1:ContainerChangeEvent) : void
|
||||
{
|
||||
if(_container == param1.oldContainer && _container != param1.newContainer)
|
||||
{
|
||||
_container = param1.newContainer;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMetadataValueAdd(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataAdd",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
|
||||
private function onMetadataValueChange(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataRemove",false,false,null,param1.key,param1.oldValue as Metadata));
|
||||
dispatchEvent(new MediaElementEvent("metadataAdd",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
|
||||
private function onMetadataValueRemove(param1:MetadataEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaElementEvent("metadataRemove",false,false,null,param1.key,param1.value as Metadata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.utils.Dictionary;
|
||||
import org.osmf.elements.ProxyElement;
|
||||
import org.osmf.events.MediaFactoryEvent;
|
||||
import org.osmf.events.PluginManagerEvent;
|
||||
import org.osmf.media.pluginClasses.PluginManager;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaFactory extends EventDispatcher
|
||||
{
|
||||
|
||||
private var pluginManager:PluginManager;
|
||||
|
||||
private var allItems:Dictionary;
|
||||
|
||||
public function MediaFactory()
|
||||
{
|
||||
super();
|
||||
allItems = new Dictionary();
|
||||
}
|
||||
|
||||
private static function getItemsByResource(param1:MediaResourceBase, param2:Vector.<MediaFactoryItem>) : Vector.<MediaFactoryItem>
|
||||
{
|
||||
var _loc4_:Vector.<MediaFactoryItem> = new Vector.<MediaFactoryItem>();
|
||||
for each(var _loc3_:MediaFactoryItem in param2)
|
||||
{
|
||||
if(_loc3_.canHandleResourceFunction(param1))
|
||||
{
|
||||
_loc4_.push(_loc3_);
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private static function getIndexOfItem(param1:String, param2:Vector.<MediaFactoryItem>) : int
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MediaFactoryItem = null;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param2.length)
|
||||
{
|
||||
_loc3_ = param2[_loc4_] as MediaFactoryItem;
|
||||
if(_loc3_.id == param1)
|
||||
{
|
||||
return _loc4_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function addItem(param1:MediaFactoryItem) : void
|
||||
{
|
||||
if(param1 == null || param1.id == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:Vector.<MediaFactoryItem> = findOrCreateItems(param1.type);
|
||||
var _loc3_:int = getIndexOfItem(param1.id,_loc2_);
|
||||
if(_loc3_ != -1)
|
||||
{
|
||||
_loc2_[_loc3_] = param1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.push(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeItem(param1:MediaFactoryItem) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(param1 == null || param1.id == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
var _loc2_:Vector.<MediaFactoryItem> = allItems[param1.type];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = _loc2_.indexOf(param1);
|
||||
if(_loc3_ != -1)
|
||||
{
|
||||
_loc2_.splice(_loc3_,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get numItems() : int
|
||||
{
|
||||
var _loc2_:* = undefined;
|
||||
var _loc3_:int = 0;
|
||||
for each(var _loc1_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc2_ = allItems[_loc1_];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ += _loc2_.length;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function getItemAt(param1:int) : MediaFactoryItem
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc2_:MediaFactoryItem = null;
|
||||
if(param1 >= 0)
|
||||
{
|
||||
for each(var _loc3_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc4_ = allItems[_loc3_];
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
if(param1 < _loc4_.length)
|
||||
{
|
||||
_loc2_ = _loc4_[param1];
|
||||
break;
|
||||
}
|
||||
param1 -= _loc4_.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function getItemById(param1:String) : MediaFactoryItem
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:MediaFactoryItem = null;
|
||||
for each(var _loc3_:String in MediaFactoryItemType.ALL_TYPES)
|
||||
{
|
||||
_loc4_ = allItems[_loc3_];
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc5_ = getIndexOfItem(param1,_loc4_);
|
||||
if(_loc5_ != -1)
|
||||
{
|
||||
_loc2_ = _loc4_[_loc5_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function loadPlugin(param1:MediaResourceBase) : void
|
||||
{
|
||||
createPluginManager();
|
||||
pluginManager.loadPlugin(param1);
|
||||
}
|
||||
|
||||
public function createMediaElement(param1:MediaResourceBase) : MediaElement
|
||||
{
|
||||
var _loc3_:MediaElement = null;
|
||||
createPluginManager();
|
||||
var _loc2_:MediaElement = createMediaElementByResource(param1,"standard");
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc3_ = createMediaElementByResource(_loc2_.resource,"proxy",_loc2_);
|
||||
_loc2_ = _loc3_ != null ? _loc3_ : _loc2_;
|
||||
dispatchEvent(new MediaFactoryEvent("mediaElementCreate",false,false,null,_loc2_));
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
protected function resolveItems(param1:MediaResourceBase, param2:Vector.<MediaFactoryItem>) : MediaFactoryItem
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:MediaFactoryItem = null;
|
||||
if(param1 == null || param2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc4_:MediaFactoryItem = null;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param2.length)
|
||||
{
|
||||
_loc3_ = param2[_loc5_] as MediaFactoryItem;
|
||||
if(_loc3_.id.indexOf("org.osmf") == -1)
|
||||
{
|
||||
return _loc3_;
|
||||
}
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
_loc4_ = _loc3_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
private function findOrCreateItems(param1:String) : Vector.<MediaFactoryItem>
|
||||
{
|
||||
if(allItems[param1] == null)
|
||||
{
|
||||
allItems[param1] = new Vector.<MediaFactoryItem>();
|
||||
}
|
||||
return allItems[param1] as Vector.<MediaFactoryItem>;
|
||||
}
|
||||
|
||||
private function createMediaElementByResource(param1:MediaResourceBase, param2:String, param3:MediaElement = null) : MediaElement
|
||||
{
|
||||
var _loc4_:MediaFactoryItem = null;
|
||||
var _loc8_:MediaElement = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:MediaFactoryItem = null;
|
||||
var _loc9_:ProxyElement = null;
|
||||
var _loc5_:MediaElement = null;
|
||||
var _loc10_:Vector.<MediaFactoryItem> = getItemsByResource(param1,allItems[param2]);
|
||||
if(param2 == "standard")
|
||||
{
|
||||
_loc4_ = resolveItems(param1,_loc10_) as MediaFactoryItem;
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc5_ = invokeMediaElementCreationFunction(_loc4_);
|
||||
}
|
||||
}
|
||||
else if(param2 == "proxy")
|
||||
{
|
||||
_loc8_ = param3;
|
||||
_loc6_ = int(_loc10_.length);
|
||||
while(_loc6_ > 0)
|
||||
{
|
||||
_loc7_ = _loc10_[_loc6_ - 1] as MediaFactoryItem;
|
||||
_loc9_ = invokeMediaElementCreationFunction(_loc7_) as ProxyElement;
|
||||
if(_loc9_ != null)
|
||||
{
|
||||
_loc9_.proxiedElement = _loc8_;
|
||||
_loc8_ = _loc9_;
|
||||
}
|
||||
_loc6_--;
|
||||
}
|
||||
_loc5_ = _loc8_;
|
||||
}
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc5_.resource = param1;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function onPluginLoad(param1:PluginManagerEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaFactoryEvent("pluginLoad",false,false,param1.resource));
|
||||
}
|
||||
|
||||
private function onPluginLoadError(param1:PluginManagerEvent) : void
|
||||
{
|
||||
dispatchEvent(new MediaFactoryEvent("pluginLoadError",false,false,param1.resource));
|
||||
}
|
||||
|
||||
private function invokeMediaElementCreationFunction(param1:MediaFactoryItem) : MediaElement
|
||||
{
|
||||
var _loc2_:MediaElement = null;
|
||||
try
|
||||
{
|
||||
_loc2_ = param1.mediaElementCreationFunction();
|
||||
}
|
||||
catch(error:Error)
|
||||
{
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function createPluginManager() : void
|
||||
{
|
||||
if(pluginManager == null)
|
||||
{
|
||||
pluginManager = new PluginManager(this);
|
||||
pluginManager.addEventListener("pluginLoad",onPluginLoad);
|
||||
pluginManager.addEventListener("pluginLoadError",onPluginLoadError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
public class MediaFactoryItem
|
||||
{
|
||||
|
||||
private var _id:String;
|
||||
|
||||
private var _canHandleResourceFunction:Function;
|
||||
|
||||
private var _mediaElementCreationFunction:Function;
|
||||
|
||||
private var _type:String;
|
||||
|
||||
public function MediaFactoryItem(param1:String, param2:Function, param3:Function, param4:String = null)
|
||||
{
|
||||
super();
|
||||
if(param1 == null || param2 == null || param3 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
if(!param4)
|
||||
{
|
||||
param4 = "standard";
|
||||
}
|
||||
_id = param1;
|
||||
_canHandleResourceFunction = param2;
|
||||
_mediaElementCreationFunction = param3;
|
||||
_type = param4;
|
||||
}
|
||||
|
||||
public function get id() : String
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public function get canHandleResourceFunction() : Function
|
||||
{
|
||||
return _canHandleResourceFunction;
|
||||
}
|
||||
|
||||
public function get mediaElementCreationFunction() : Function
|
||||
{
|
||||
return _mediaElementCreationFunction;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public class MediaFactoryItemType
|
||||
{
|
||||
|
||||
public static const STANDARD:String = "standard";
|
||||
|
||||
public static const PROXY:String = "proxy";
|
||||
|
||||
internal static const ALL_TYPES:Array = ["standard","proxy"];
|
||||
|
||||
public function MediaFactoryItemType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
public final class MediaPlayerState
|
||||
{
|
||||
|
||||
public static const UNINITIALIZED:String = "uninitialized";
|
||||
|
||||
public static const LOADING:String = "loading";
|
||||
|
||||
public static const READY:String = "ready";
|
||||
|
||||
public static const PLAYING:String = "playing";
|
||||
|
||||
public static const PAUSED:String = "paused";
|
||||
|
||||
public static const BUFFERING:String = "buffering";
|
||||
|
||||
public static const PLAYBACK_ERROR:String = "playbackError";
|
||||
|
||||
public function MediaPlayerState()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class MediaResourceBase
|
||||
{
|
||||
|
||||
private var _metadata:Dictionary;
|
||||
|
||||
private var _mediaType:String;
|
||||
|
||||
private var _mimeType:String;
|
||||
|
||||
public function MediaResourceBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get mediaType() : String
|
||||
{
|
||||
return _mediaType;
|
||||
}
|
||||
|
||||
public function set mediaType(param1:String) : void
|
||||
{
|
||||
_mediaType = param1;
|
||||
}
|
||||
|
||||
public function get mimeType() : String
|
||||
{
|
||||
return _mimeType;
|
||||
}
|
||||
|
||||
public function set mimeType(param1:String) : void
|
||||
{
|
||||
_mimeType = param1;
|
||||
}
|
||||
|
||||
public function get metadataNamespaceURLs() : Vector.<String>
|
||||
{
|
||||
var _loc1_:Vector.<String> = new Vector.<String>();
|
||||
if(_metadata != null)
|
||||
{
|
||||
for(var _loc2_:String in _metadata)
|
||||
{
|
||||
_loc1_.push(_loc2_);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function addMetadataValue(param1:String, param2:Object) : void
|
||||
{
|
||||
if(_metadata == null)
|
||||
{
|
||||
_metadata = new Dictionary();
|
||||
}
|
||||
_metadata[param1] = param2;
|
||||
}
|
||||
|
||||
public function getMetadataValue(param1:String) : Object
|
||||
{
|
||||
if(_metadata != null)
|
||||
{
|
||||
return _metadata[param1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function removeMetadataValue(param1:String) : Object
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(_metadata != null)
|
||||
{
|
||||
_loc2_ = _metadata[param1];
|
||||
delete _metadata[param1];
|
||||
return _loc2_;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.osmf.media
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import org.osmf.traits.MediaTraitBase;
|
||||
import org.osmf.utils.OSMFStrings;
|
||||
|
||||
internal class MediaTraitResolver extends EventDispatcher
|
||||
{
|
||||
|
||||
private var _type:String;
|
||||
|
||||
private var _resolvedTrait:MediaTraitBase;
|
||||
|
||||
public function MediaTraitResolver(param1:String)
|
||||
{
|
||||
super();
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
_type = param1;
|
||||
}
|
||||
|
||||
final public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
final protected function setResolvedTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 != _resolvedTrait)
|
||||
{
|
||||
if(_resolvedTrait)
|
||||
{
|
||||
_resolvedTrait = null;
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
_resolvedTrait = param1;
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
}
|
||||
|
||||
final public function get resolvedTrait() : MediaTraitBase
|
||||
{
|
||||
return _resolvedTrait;
|
||||
}
|
||||
|
||||
final public function addTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param1.traitType != type)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
processAddTrait(param1);
|
||||
}
|
||||
|
||||
final public function removeTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
if(param1 == null)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("nullParam"));
|
||||
}
|
||||
if(param1.traitType != type)
|
||||
{
|
||||
throw new ArgumentError(OSMFStrings.getString("invalidParam"));
|
||||
}
|
||||
return processRemoveTrait(param1);
|
||||
}
|
||||
|
||||
protected function processAddTrait(param1:MediaTraitBase) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function processRemoveTrait(param1:MediaTraitBase) : MediaTraitBase
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 7925 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user