home *** CD-ROM | disk | FTP | other *** search
Wrap
class mx.controls.MediaPlayback extends mx.core.UIComponent { var _deadPreview; var initCuePointTimes; var initCuePointNames; var _totalTime; var _aspectRatio; var _autoSize; var _autoPlay; var _mediaType; var _contentPath; var _controllerPolicy; var _controller; var _display; var _enabled; var _chrome; var dispatchEvent; var _controlPlacement; static var symbolName = "MediaPlayback"; static var symbolOwner = mx.controls.MediaPlayback; var className = "MediaPlayback"; static var version = "2.0.1.78"; var clipParameters = {mediaType:"FLV",contentPath:"",totalTime:0,autoSize:true,autoPlay:true,controllerPolicy:"auto",initCuePointNames:new Array(),initCuePointTimes:new Array(),controlPlacement:"bottom",fps:30}; static var TOP_CONTROL_POSITION = "top"; static var BOTTOM_CONTROL_POSITION = "bottom"; static var LEFT_CONTROL_POSITION = "left"; static var RIGHT_CONTROL_POSITION = "right"; static var H_BORDER = 8; static var V_BORDER = 8; var _settingMedia = false; function MediaPlayback() { super(); } function init(Void) { this.initializeParameters(); var _loc5_ = this._width; var _loc8_ = this._height; this._deadPreview._visible = false; super.init(); var _loc3_ = {contentPath:this._contentPath,mediaType:this._mediaType,autoPlay:this._autoPlay,autoSize:this._autoSize,aspectRatio:this._aspectRatio,totalTime:this._totalTime,initCuePointNames:this.initCuePointNames,initCuePointTimes:this.initCuePointTimes}; this.attachMovie("MediaDisplay","_display",1,_loc3_); var _loc4_ = !this._autoPlay ? mx.controls.streamingmedia.StreamingMediaConstants.PLAY_PLAY_CONTROL : mx.controls.streamingmedia.StreamingMediaConstants.PAUSE_PLAY_CONTROL; var _loc6_ = this._mediaType != "MP3" ? "none" : "default"; var _loc7_ = this.controlPlacement == "top" || this.controlPlacement == "bottom"; _loc3_ = {horizontal:_loc7_,controllerPolicy:this._controllerPolicy,backgroundStyle:_loc6_,activePlayControl:_loc4_}; this.attachMovie("MediaController","_controller",2,_loc3_); this.setSize(_loc5_,_loc8_,true); this._display.associateController(this._controller); this._controller.addEventListener("click",this); this._controller.addEventListener("playheadChange",this); this._controller.addEventListener("volume",this); this._controller.addEventListener("scrubbing",this); this._display.addEventListener("change",this); this._display.addEventListener("progress",this); this._display.addEventListener("start",this); this._display.addEventListener("resizeVideo",this); this._display.addEventListener("cuePoint",this); this._display.addEventListener("complete",this); this._enabled = true; this.tabEnabled = false; this.tabChildren = true; this.redraw(true); } function initializeParameters() { if(this.mediaType == null) { this.mediaType = "FLV"; } if(this.totalTime == null) { this.totalTime = 0; } if(this.contentPath == null) { this.contentPath = ""; } if(this.autoPlay == null) { this.autoPlay = true; } if(this.autoSize == null) { this.autoSize = true; } if(this.aspectRatio == null) { this.aspectRatio = true; } if(this.controllerPolicy == null) { this.controllerPolicy = "auto"; } if(this.controlPlacement == null) { this.controlPlacement = "bottom"; } } function draw(Void) { if(this._mediaType == "MP3") { this.drawMP3(); } else { this.drawFLV(); } } function drawMP3() { this._display._x = 0; this._display._y = 0; this._controller._x = 0; this._controller._y = 0; this._controller.setSize(this.width,this.height,true); this._controller.backgroundStyle = "default"; this._controller.setOpenUpOrLeft(false); this._controller.redraw(true); this._chrome.visible = false; this._chrome.showToggles = false; this._chrome.draw(); } function drawFLV() { this.drawChrome(); this.drawFLVController(); this.drawFLVDisplay(); } function drawChrome() { var _loc3_ = undefined; var _loc2_ = undefined; if(this._controller.horizontal) { _loc2_ = this.height - this._controller.getMinimumOpenHeight() + this._controller.getMinimumClosedHeight(); _loc3_ = this.width; } else { _loc3_ = this.width - this._controller.getMinimumOpenWidth() + this._controller.getMinimumClosedWidth(); _loc2_ = this.height; } var _loc4_ = this.width; var _loc5_ = this.height; var _loc8_ = this._controllerPolicy != "on" ? _loc3_ : _loc4_; var _loc7_ = this._controllerPolicy != "on" ? _loc2_ : _loc5_; var _loc6_ = this.isTopControlPlacement() || this.isLeftControlPlacement(); this._chrome._x = 0; this._chrome._y = 0; if(this.isTopControlPlacement() && (this._controllerPolicy == "off" || this._controllerPolicy == "auto")) { this._chrome._y = this._controller.getMinimumOpenHeight() - this._controller.getMinimumClosedHeight(); } else if(this.isLeftControlPlacement() && (this._controllerPolicy == "off" || this._controllerPolicy == "auto")) { this._chrome._x = this._controller.getMinimumOpenWidth() - this._controller.getMinimumClosedWidth(); } this._chrome.visible = true; this._chrome.showToggles = true; this._chrome.setSize(_loc8_,_loc7_); this._chrome.draw(); this.addSecondChrome(this._chrome,_loc2_,_loc5_,_loc3_,_loc4_,_loc6_); } function drawFLVController() { if(this.isBottomControlPlacement()) { this._controller.setSize(this.width,this._controller.getMinimumOpenHeight(),true); this._controller.horizontal = true; this._controller._x = 0; this._controller._y = this.height - this._controller.height; } else if(this.isTopControlPlacement()) { this._controller.setSize(this.width,this._controller.getMinimumOpenHeight(),true); this._controller.horizontal = true; this._controller.setOpenUpOrLeft(true); this._controller._x = 0; if(this._controllerPolicy == "on") { this._controller._y = 0; } else { this._controller._y = this._controller.height - this._controller.getMinimumClosedHeight(); } } else if(this.isRightControlPlacement()) { this._controller.setSize(this._controller.getMinimumOpenWidth(),this.height,true); this._controller.horizontal = false; this._controller._x = this.width - this._controller.width; this._controller._y = 0; } else if(this.isLeftControlPlacement()) { this._controller.setSize(this._controller.getMinimumOpenWidth(),this.height,true); this._controller.horizontal = false; this._controller.setOpenUpOrLeft(true); if(this._controllerPolicy == "on") { this._controller._x = 0; } else { this._controller._x = this._controller.width - this._controller.getMinimumClosedWidth(); } this._controller._y = 0; } this._controller.backgroundStyle = "none"; this._controller.invalidate(); } function drawFLVDisplay() { this.displaySetProperSize(); var _loc3_ = 0; var _loc2_ = 0; if(this.isTopControlPlacement()) { _loc2_ = this._controller.height; } else if(this.isLeftControlPlacement()) { _loc3_ = this._controller.width; } this._display._x = _loc3_ + mx.controls.MediaPlayback.H_BORDER; this._display._y = _loc2_ + mx.controls.MediaPlayback.V_BORDER; } function displaySetProperSize() { var _loc2_ = this.width - mx.controls.MediaPlayback.H_BORDER * 2; var _loc3_ = this.height - mx.controls.MediaPlayback.V_BORDER * 2; if(this.isBottomControlPlacement() || this.isTopControlPlacement()) { _loc3_ -= this._controller.height; } else { _loc2_ -= this._controller.width; } if(this._autoSize && (this._display.preferredWidth > _loc2_ || this._display.preferredHeight > _loc3_)) { this._display.autoSize = false; this._display.aspectRatio = true; } else { this._display.autoSize = this._autoSize; this._display.aspectRatio = this._aspectRatio; } this._display.setSize(_loc2_,_loc3_,true); this._display.invalidate(); } function handleEvent(ev) { ev.target = this; this.dispatchEvent(ev); if(ev.type == "start") { if(this._mediaType == "FLV") { this._display.makeVideoVisible = true; this.redraw(true); } else if(this._mediaType == "MP3") { this._controller.setPlaying(this._display.playing); } } if(ev.type == "resizeVideo") { if(this._mediaType == "FLV") { this._display.makeVideoVisible = true; this.redraw(true); } } } function toString() { return "MediaPlayback: media=" + this._contentPath; } function getController() { return this._controller; } function isRtmp(mediaUrl) { if(this._display != null) { return this._display.isRtmp(mediaUrl); } return false; } function load() { this._display.load(); } function play(startingPoint) { this._display.play(startingPoint); this._controller.setPlaying(true); } function pause() { this._display.pause(); this._controller.setPlaying(false); } function stop() { this._display.stop(); this._controller.setPlaying(false); } function get autoSize() { if(this._display != null) { this._autoSize = this._display.autoSize; } return this._autoSize; } function set autoSize(flag) { this._autoSize = flag; if(this._display != null) { this.displaySetProperSize(); this.invalidate(); } } function get aspectRatio() { if(this._display != null) { this._aspectRatio = this._display.aspectRatio; } return this._aspectRatio; } function set aspectRatio(flag) { this._aspectRatio = flag; if(this._display != null) { this.displaySetProperSize(); this.invalidate(); } } function get autoPlay() { if(this._display != null) { this._autoPlay = this._display.autoPlay; } return this._autoPlay; } function set autoPlay(flag) { this._autoPlay = flag; if(this._display != null) { this._display.autoPlay = flag; } } function get playheadTime() { return this._display.playheadTime; } function set playheadTime(position) { this._display.playheadTime = position; } function get contentPath() { if(this._display != null) { this._contentPath = this._display.contentPath; } return this._contentPath; } function set contentPath(aUrl) { this._contentPath = aUrl; if(this._display != null) { if(!this._settingMedia) { this._display.contentPath = aUrl; } this._mediaType = this._display.mediaType; } } function get volume() { return this._display.volume; } function set volume(aVol) { this._display.volume = aVol; this._controller.volume = aVol; } function get playing() { return this._display.playing; } function get preferredWidth() { return this._display.preferredWidth; } function get preferredHeight() { return this._display.preferredHeight; } function get bytesLoaded() { return this._display.bytesLoaded; } function get bytesTotal() { return this._display.bytesTotal; } function get mediaType() { if(this._display != null) { this._mediaType = this._display.mediaType; } return this._mediaType; } function set mediaType(aType) { this._mediaType = aType; if(this._display != null) { this._display.mediaType = aType; if(aType == "MP3") { this._controller.backgroundStyle = "none"; this.removeSecondChrome(); } else { this._controller.backgroundStyle = "default"; this.drawChrome(); } this.invalidate(); } } function setMedia(aUrl, aType) { this._settingMedia = true; var _loc5_ = this._mediaType; this._display.setMedia(aUrl,aType); if(aType == null) { var _loc3_ = aUrl.substr(-3); if(_loc3_ == "flv" || _loc3_ == "FLV") { aType = "FLV"; } else if(_loc3_ == "mp3" || _loc3_ == "MP3") { aType = "MP3"; } else { aType = this._mediaType; } } if(_loc5_ != aType) { this.mediaType = aType; } this.contentPath = aUrl; this._settingMedia = false; } function get totalTime() { if(this._display != null) { this._totalTime = this._display.totalTime; } return this._totalTime; } function set totalTime(aTime) { this._totalTime = aTime; if(this._display != null) { this._display.totalTime = this._totalTime; } } function getCuePoints() { return this._display.getCuePoints(); } function get cuePoints() { return this.getCuePoints(); } function setCuePoints(cp) { var _loc2_ = 0; while(_loc2_ < cp.length) { cp[_loc2_].playback = this; _loc2_ = _loc2_ + 1; } this._display.cuePoints = cp; } function set cuePoints(cp) { this.setCuePoints(cp); } function getCuePoint(pointName) { return this._display.getCuePoint(pointName); } function addCuePoint(aName, aTime) { var _loc2_ = new mx.controls.streamingmedia.CuePoint(aName,aTime); _loc2_.playback = this; this.addCuePointObject(_loc2_); } function addCuePointObject(aCuePoint) { aCuePoint.playback = this; this._display.addCuePointObject(aCuePoint); } function removeCuePoint(aCuePoint) { this._display.removeCuePoint(aCuePoint); } function removeAllCuePoints() { this._display.removeAllCuePoints(); } function get mostRecentCuePoint() { return this._display.mostRecentCuePoint; } function get mostRecentCuePointName() { return this._display.mostRecentCuePointName; } function get mostRecentCuePointTime() { return this._display.mostRecentCuePointTime; } function get controllerPolicy() { if(this._controller != null) { this._controllerPolicy = this._controller.controllerPolicy; } return this._controllerPolicy; } function set controllerPolicy(aPolicy) { this._controllerPolicy = aPolicy; if(this._controller != null) { this._controller.controllerPolicy = aPolicy; } } function addSecondChrome(theChrome, closedHeight, openHeight, closedWidth, openWidth, fixedEnd) { this._controller.addSecondChrome(theChrome,closedHeight,openHeight,closedWidth,openWidth,fixedEnd); } function removeSecondChrome() { this._controller.removeSecondChrome(); } function getMinimumOpenHeight() { return this._controller.getMinimumOpenHeight(); } function getMinimumOpenWidth() { return this._controller.getMinimumOpenWidth(); } function getMinimumClosedHeight() { return this._controller.getMinimumClosedHeight(); } function getMinimumClosedWidth() { return this._controller.getMinimumClosedWidth(); } function expand(force) { this._controller.expand(force); } function contract(force) { this._controller.contract(force); } function get controlPlacement() { return this._controlPlacement; } function set controlPlacement(aPos) { this._controlPlacement = aPos; if(this._controller != null) { var _loc2_ = this.isTopControlPlacement() || this.isLeftControlPlacement(); this._controller.setOpenUpOrLeft(_loc2_); var _loc3_ = this.isTopControlPlacement() || this.isBottomControlPlacement(); this._controller.horizontal = _loc3_; this.invalidate(); } } function isTopControlPlacement() { return this._controlPlacement == mx.controls.MediaPlayback.TOP_CONTROL_POSITION; } function isBottomControlPlacement() { return this._controlPlacement == mx.controls.MediaPlayback.BOTTOM_CONTROL_POSITION; } function isLeftControlPlacement() { return this._controlPlacement == mx.controls.MediaPlayback.LEFT_CONTROL_POSITION; } function isRightControlPlacement() { return this._controlPlacement == mx.controls.MediaPlayback.RIGHT_CONTROL_POSITION; } function displayFull() { var _loc2_ = this._chrome.getOneToggle(); _loc2_.displayFull(false); } function displayNormal() { var _loc2_ = this._chrome.getOneToggle(); _loc2_.displayNormal(false); } function setSize(w, h, noEvent) { w = Math.max(w,this._controller.getMinimumOpenWidth() + 17); h = Math.max(h,this._controller.getMinimumOpenHeight() + 17); super.setSize(w,h,noEvent); this.invalidate(); } function get enabled() { return this._enabled; } function set enabled(is) { this._enabled = is; this._display.enabled = is; this._controller.enabled = is; this._chrome.setEnabled(is); } }