home *** CD-ROM | disk | FTP | other *** search
- package
- {
- import com.adobe.xmp.core.XMPMeta;
- import com.brooksandrus.events.CaptionEvent;
- import com.brooksandrus.events.VideoMetadataEvent;
- import com.brooksandrus.events.VideoStreamEvent;
- import com.brooksandrus.player.MediaPlayer;
- import com.brooksandrus.player.XMPData;
- import com.techsmith.events.LockTocEvent;
- import com.techsmith.events.RequestBinaryImageEvent;
- import com.techsmith.ui.FloatingToc;
- import com.techsmith.utils.URLBinaryStream;
- import flash.accessibility.*;
- import flash.debugger.*;
- import flash.display.*;
- import flash.errors.*;
- import flash.events.*;
- import flash.external.*;
- import flash.filters.*;
- import flash.geom.*;
- import flash.media.*;
- import flash.net.*;
- import flash.printing.*;
- import flash.profiler.*;
- import flash.system.*;
- import flash.text.*;
- import flash.ui.*;
- import flash.utils.*;
- import flash.xml.*;
- import mx.binding.*;
- import mx.containers.Canvas;
- import mx.core.IFlexModuleFactory;
- import mx.core.UIComponentDescriptor;
- import mx.effects.Tween;
- import mx.events.DragEvent;
- import mx.events.FlexEvent;
- import mx.events.ListEvent;
- import mx.events.PropertyChangeEvent;
- import mx.events.TweenEvent;
- import mx.styles.*;
-
- public class FloatingTOCMedia extends Canvas
- {
- private var _103772132media:MediaPlayer;
-
- private var _3568542tree:FloatingToc;
-
- private var _documentDescriptor_:UIComponentDescriptor = new UIComponentDescriptor({
- "type":Canvas,
- "stylesFactory":function():void
- {
- this.backgroundColor = 0;
- },
- "propertiesFactory":function():Object
- {
- return {
- "height":450,
- "width":960,
- "childDescriptors":[new UIComponentDescriptor({
- "type":MediaPlayer,
- "id":"media",
- "propertiesFactory":function():Object
- {
- return {"dockingtoc":true};
- }
- }),new UIComponentDescriptor({
- "type":FloatingToc,
- "id":"tree",
- "events":{"creationComplete":"__tree_creationComplete"},
- "propertiesFactory":function():Object
- {
- return {
- "height":300,
- "width":230,
- "x":-230,
- "y":0
- };
- }
- })]
- };
- }
- });
-
- private var __moduleFactoryInitialized:Boolean = false;
-
- private var xmpData:XMPData = null;
-
- private var iStream:URLBinaryStream = null;
-
- private var dock:String = "left";
-
- private var dragging:Boolean = false;
-
- private var sliding:Boolean = false;
-
- private var slidingIn:Boolean = false;
-
- private var slidingOut:Boolean = false;
-
- private var tocHidden:Boolean = true;
-
- private var isTyping:Boolean = false;
-
- private var tween:Tween;
-
- private var tween2:Tween;
-
- private var treepos:Number = -230;
-
- private var mediapos:Number = 0;
-
- private var videoActive:Boolean;
-
- private var delayTimer:Timer;
-
- private var mouseTimer:Timer;
-
- private var funcx:Function = null;
-
- private var fullscreenTimer:Timer;
-
- private var _mouseHide:Boolean = false;
-
- private var _tocklock:Boolean = false;
-
- private var showToc:Boolean;
-
- private var lastunscaledWidth:Number;
-
- private var lastunscaledHeight:Number;
-
- public function FloatingTOCMedia()
- {
- super();
- mx_internal::_document = this;
- this.height = 450;
- this.horizontalScrollPolicy = "off";
- this.verticalScrollPolicy = "off";
- this.width = 960;
- }
-
- override public function set moduleFactory(param1:IFlexModuleFactory) : void
- {
- var factory:IFlexModuleFactory = param1;
- super.moduleFactory = factory;
- if(this.__moduleFactoryInitialized)
- {
- return;
- }
- this.__moduleFactoryInitialized = true;
- if(!this.styleDeclaration)
- {
- this.styleDeclaration = new CSSStyleDeclaration(null,styleManager);
- }
- this.styleDeclaration.defaultFactory = function():void
- {
- this.backgroundColor = 0;
- };
- }
-
- override public function initialize() : void
- {
- mx_internal::setDocumentDescriptor(this._documentDescriptor_);
- super.initialize();
- }
-
- public function init(param1:XMPMeta) : void
- {
- var xmp:XMPMeta = param1;
- this.xmpData = new XMPData(xmp);
- this.showToc = this.media.config.showToc;
- this.delayTimer = new Timer(700,1);
- this.mouseTimer = new Timer(3000,1);
- this.mouseTimer.addEventListener(TimerEvent.TIMER_COMPLETE,this.slideOutTOCTimer);
- if(xmp == null)
- {
- this.showToc = false;
- }
- if(!this.showToc)
- {
- this.tree.visible = false;
- this._tocklock = true;
- }
- else
- {
- this.setTocPosition(this.media.config.tocType);
- if(this.xmpData.title != null)
- {
- this.tree.title = this.xmpData.title;
- }
- if(this.xmpData.toc != null)
- {
- if(this.xmpData.tocimage != null)
- {
- this.tree.tocImage(this.xmpData.tocimage);
- }
- this.tree.dataProvider = this.xmpData.toc.children();
- this.tree.validateNow();
- this.tree.expandChildrenOf(0,true);
- }
- else if(!this.media.config.showSearch || this.xmpData.searchData.length == 0)
- {
- this.showToc = false;
- this.tree.visible = false;
- this._tocklock = true;
- }
- if(this.media.config.showSearch && this.xmpData.searchData.length >= 0)
- {
- this.tree.searchData = this.xmpData.searchData;
- this.tree.setLocalizedTocText(this.xmpData.getLocalizedText("x-default"));
- }
- if(this.xmpData.captions != null)
- {
- this.media.initiateCaptions(this.xmpData.captions);
- if(ExternalInterface.available)
- {
- try
- {
- ExternalInterface.call("hasCaptions");
- }
- catch(e:Error)
- {
- }
- }
- }
- if(this.xmpData.hotspots != null)
- {
- this.media.initiateHS(this.xmpData.hotspots);
- }
- if(this.showToc)
- {
- this.tree.setColor(this.media.config.colorObj);
- this.tree.validateNow();
- }
- }
- if(this.showToc)
- {
- this.tree.addEventListener(RequestBinaryImageEvent.BYTE_REQUEST,this.getbinaryImage);
- this.tree.addEventListener(KeyboardEvent.KEY_DOWN,this.isTypingHandler);
- }
- if(String(this.xmpData.groupthumbs) != "null")
- {
- this.iStream = new URLBinaryStream(this.xmpData.groupthumbs);
- }
- this.media.setLocalizedText(this.xmpData.getLocalizedText("x-default"));
- this.media.addEventListener(VideoStreamEvent.STARTED,this.playbackStartedHandler,false,0,true);
- this.media.addEventListener(FullScreenEvent.FULL_SCREEN,this.fullscreenHandler);
- this.media.addEventListener(CaptionEvent.CAPTIONS_LANG_CHANGE,this.captionChangeHandler);
- }
-
- private function captionChangeHandler(param1:CaptionEvent) : void
- {
- if(this.media.config.showSearch && this.xmpData.searchwithCaptionData(param1.lang).length >= 0)
- {
- this.tree.searchData = this.xmpData.searchwithCaptionData(param1.lang);
- this.tree.setLocalizedTocText(this.xmpData.getLocalizedText(param1.lang));
- this.media.setLocalizedText(this.xmpData.getLocalizedText(param1.lang));
- }
- }
-
- private function isTypingHandler(param1:KeyboardEvent) : void
- {
- this.isTyping = true;
- this.delayFunction(8000,this.funcx);
- }
-
- private function getbinaryImage(param1:RequestBinaryImageEvent) : void
- {
- var _loc2_:ByteArray = this.iStream.getBytesArray(param1.offset);
- param1.target.ByteLoader(_loc2_,param1.offset,param1.uid);
- }
-
- private function fullscreenHandler(param1:FullScreenEvent) : void
- {
- if(param1.fullScreen)
- {
- this.setfullscreenMouseTimer();
- this.addEventListener(MouseEvent.MOUSE_MOVE,this.fullscreenMouseMoveHandler);
- }
- else
- {
- Mouse.show();
- this.mouseTimer.stop();
- this.mouseTimer.reset();
- this.removeEventListener(MouseEvent.MOUSE_MOVE,this.fullscreenMouseMoveHandler);
- }
- if(this.showToc)
- {
- this.tree.fullscreen(param1.fullScreen);
- }
- }
-
- private function fullscreenMouseMoveHandler(param1:MouseEvent) : void
- {
- if(this._mouseHide)
- {
- this._mouseHide = false;
- Mouse.show();
- }
- this.delayFunction(300,this.delayHandlerIN);
- this.setfullscreenMouseTimer();
- }
-
- private function setfullscreenMouseTimer() : void
- {
- this.mouseTimer.stop();
- this.mouseTimer.reset();
- this.mouseTimer.start();
- }
-
- private function slideOutTOCTimer(param1:TimerEvent) : void
- {
- this.delayFunction(600,this.delayHandlerOUT);
- Mouse.hide();
- this._mouseHide = true;
- }
-
- private function setTocPosition(param1:String) : void
- {
- if(param1 == "l")
- {
- this.tree.x = -230;
- this.dock = "left";
- }
- if(param1 == "r")
- {
- this.dock = "right";
- this.tree.x = unscaledWidth;
- this.treepos = this.tree.x;
- this.mediapos = 0;
- }
- if(param1 == "f")
- {
- this.dock = "float";
- this.tree.x = (unscaledWidth - this.tree.width) / 3;
- this.tree.y = (unscaledHeight - (400 + this.media.controls.height)) / 2;
- this.treepos = 0;
- if(this.media.config.showStartScreen)
- {
- this.tree.visible = false;
- }
- }
- this.tree.docktype = this.dock;
- }
-
- private function itemClickHandler(param1:ListEvent) : void
- {
- var metaHandler:Function;
- var time:Number = NaN;
- var e:ListEvent = param1;
- var item:XML = e.itemRenderer.data as XML;
- var milliseconds:int = parseInt(item.@startTime);
- time = milliseconds / 1000;
- if(!this.media.loaded)
- {
- metaHandler = function():void
- {
- media.replayfromToc(time);
- };
- this.media.addEventListener(VideoMetadataEvent.VIDEO_METADATA,metaHandler,false,0,true);
- this.media.play();
- }
- else
- {
- this.media.replayfromToc(time,true);
- }
- }
-
- private function registerlisteners() : void
- {
- this.addEventListener(MouseEvent.ROLL_OVER,this.mouseOverHandler,false,0,false);
- this.addEventListener(MouseEvent.ROLL_OUT,this.mouseOutHandler,false,0,false);
- this.tree.addEventListener(DragEvent.DRAG_START,this.dragstart);
- this.tree.addEventListener(DragEvent.DRAG_COMPLETE,this.dragstop);
- this.tree.addEventListener(ListEvent.ITEM_CLICK,this.itemClickHandler);
- this.tree.addEventListener(LockTocEvent.TOC_LOCK,this.tockLockHandler);
- }
-
- private function dragstart(param1:DragEvent) : void
- {
- this.dragging = true;
- this.dock = "float";
- this.tree.startDrag();
- this.tree.height = 400;
- this.tree.docktype = this.dock;
- this.invalidateDisplayList();
- }
-
- private function dragstop(param1:DragEvent) : void
- {
- this.tree.stopDrag();
- this.dragging = false;
- this.dragEnterFrame(new Event(Event.COMPLETE));
- this.tree.docktype = this.dock;
- invalidateDisplayList();
- }
-
- private function dragEnterFrame(param1:Event) : void
- {
- if(this.tree.x <= 7)
- {
- this.dock = "left";
- this.treepos = 0;
- this.mediapos = this.tree.width;
- }
- if(this.tree.x >= this.width - (7 + this.tree.width))
- {
- this.dock = "right";
- this.treepos = this.unscaledWidth - 230;
- if(this.mediapos == 0)
- {
- this.mediapos = this.unscaledWidth - this.treepos;
- }
- }
- if(this.tree.x > 7 && this.tree.x < this.width - (7 + this.tree.width))
- {
- this.dock = "float";
- }
- }
-
- private function playbackStartedHandler(param1:Event) : void
- {
- this.videoActive = true;
- if(this.showToc == false)
- {
- this.slideInTOC();
- }
- else
- {
- this.delayFunction(1000,this.delayHandlerIN);
- }
- }
-
- private function replayHandler(param1:Event) : void
- {
- var _loc2_:Boolean = false;
- this.videoActive = true;
- if(this.showToc)
- {
- _loc2_ = this._tocklock;
- this._tocklock = false;
- this.slideInTOC();
- this._tocklock = _loc2_;
- }
- }
-
- private function playbackFinishedHandler(param1:VideoStreamEvent) : void
- {
- var _loc2_:Boolean = false;
- if(this.media.config.showEndScreen)
- {
- _loc2_ = this._tocklock;
- this._tocklock = false;
- this.slideOutTOC();
- this._tocklock = _loc2_;
- this.videoActive = false;
- }
- }
-
- private function delayFunction(param1:Number, param2:Function) : void
- {
- if(this.funcx !== null)
- {
- this.delayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.funcx);
- }
- this.delayTimer.delay = param1;
- this.funcx = param2;
- this.delayTimer.stop();
- this.delayTimer.reset();
- this.delayTimer.addEventListener(TimerEvent.TIMER_COMPLETE,param2);
- this.delayTimer.start();
- }
-
- private function tockLockHandler(param1:LockTocEvent) : void
- {
- this._tocklock = param1.selected;
- }
-
- private function delayHandlerIN(param1:TimerEvent) : void
- {
- this.slideInTOC();
- if(this.dragging)
- {
- this.dragstop(new DragEvent(DragEvent.DRAG_COMPLETE));
- invalidateDisplayList();
- }
- }
-
- private function delayHandlerOUT(param1:TimerEvent) : void
- {
- if(this.dragging)
- {
- this.dragstop(new DragEvent(DragEvent.DRAG_COMPLETE));
- invalidateDisplayList();
- }
- this.delayFunction(250,this.delayTocSlideOut);
- }
-
- private function delayTocSlideOut(param1:TimerEvent) : void
- {
- this.slideOutTOC();
- }
-
- private function delayHandlerEndscreen(param1:TimerEvent) : void
- {
- var _loc2_:Boolean = this._tocklock;
- this.slideOutTOC();
- if(this.dragging)
- {
- this.dragstop(new DragEvent(DragEvent.DRAG_COMPLETE));
- invalidateDisplayList();
- }
- this.videoActive = false;
- }
-
- private function mouseOverHandler(param1:MouseEvent) : void
- {
- if(this.showToc == false)
- {
- this.slideInTOC();
- }
- else
- {
- this.delayFunction(600,this.delayHandlerIN);
- }
- if(this.dragging)
- {
- this.tree.stopDrag();
- }
- }
-
- private function mouseOutHandler(param1:MouseEvent) : void
- {
- if(this.showToc == false)
- {
- this.slideOutTOC();
- }
- else if(this.isTyping)
- {
- this.delayFunction(8000,this.delayHandlerOUT);
- }
- else
- {
- this.delayFunction(600,this.delayHandlerOUT);
- }
- if(this.dragging)
- {
- this.tree.stopDrag();
- }
- }
-
- private function slideInTOC() : void
- {
- if(this.media.config.showStartScreen && !this.media.config.autoStart && !this.videoActive || this._tocklock)
- {
- if(this.showToc == false)
- {
- this.media.mouseOverHandler(new MouseEvent(MouseEvent.MOUSE_OVER));
- }
- return;
- }
- if(this.sliding)
- {
- this.tween.pause();
- }
- if(this.tween2)
- {
- this.tween2.pause();
- }
- if(this.dock == "left")
- {
- this.tween = new Tween(this,this.tree.x,0,900,60,this.slidingInLeftHandler,this.slidingInLeftEndHandler);
- this.tween.easingFunction = this.easit;
- }
- if(this.dock == "right")
- {
- this.tween = new Tween(this,this.tree.x,this.unscaledWidth - this.tree.width,900,60,this.slidingInRightHandler,this.slidingInRightEndHandler);
- this.tween.easingFunction = this.easit;
- }
- if(this.media.config.autoHide || this.dock == "float")
- {
- this.tween2 = new Tween(this,this.tree.alpha,1,500,60,this.fadeHandler,this.FadeEndHandler);
- }
- }
-
- private function slidingInLeftHandler(param1:Number) : void
- {
- this.sliding = true;
- this.treepos = param1;
- this.mediapos = this.treepos + 230;
- this.invalidateDisplayList();
- }
-
- private function slidingInLeftEndHandler(param1:Number) : void
- {
- this.treepos = param1;
- this.mediapos = this.treepos + 230;
- this.sliding = false;
- this.invalidateDisplayList();
- if(this.isTyping)
- {
- stage.focus = null;
- this.isTyping = false;
- }
- }
-
- private function slidingInRightHandler(param1:Number) : void
- {
- this.sliding = true;
- this.treepos = param1;
- this.mediapos = this.unscaledWidth - param1;
- this.invalidateDisplayList();
- }
-
- private function slidingInRightEndHandler(param1:Number) : void
- {
- this.treepos = param1;
- this.mediapos = this.unscaledWidth - param1;
- this.sliding = false;
- this.invalidateDisplayList();
- if(this.isTyping)
- {
- stage.focus = null;
- this.isTyping = false;
- }
- }
-
- public function easit(param1:Number, param2:Number, param3:Number, param4:Number) : Number
- {
- param1 = param1 / param4;
- var _loc5_:Number = param1 * param1;
- var _loc6_:Number = _loc5_ * param1;
- return param2 + param3 * (6 * _loc6_ * _loc5_ + -15 * _loc5_ * _loc5_ + 10 * _loc6_ + 0 * _loc5_ + 0 * param1);
- }
-
- private function slideOutTOC() : void
- {
- trace("slideOut");
- if(this.media.config.showStartScreen && !this.media.config.autoStart && !this.videoActive || this._tocklock)
- {
- if(this.showToc == false)
- {
- this.media.mouseOutHandler(new MouseEvent(MouseEvent.MOUSE_OUT));
- }
- return;
- }
- if(this.sliding)
- {
- this.tween.pause();
- }
- if(this.tween2)
- {
- this.tween2.pause();
- }
- if(this.dock == "left")
- {
- this.tween = new Tween(this,this.tree.x,-this.tree.width,900,60,this.slidingInLeftHandler,this.slidingInLeftEndHandler);
- this.tween.easingFunction = this.easit;
- }
- if(this.dock == "right")
- {
- this.tween = new Tween(this,this.tree.x,this.unscaledWidth,900,60,this.slidingInRightHandler,this.slidingInRightEndHandler);
- this.tween.easingFunction = this.easit;
- }
- if(this.media.config.autoHide || this.dock == "float")
- {
- this.tween2 = new Tween(this,this.tree.alpha,0,500,60,this.fadeHandler,this.FadeEndHandler);
- }
- }
-
- private function fadeHandler(param1:Number) : void
- {
- this.tree.visible = true;
- this.tree.alpha = param1;
- if(this.media.config.autoHide)
- {
- this.media.controls.alpha = param1;
- }
- if(this.media.config.autoHide && this.media._hasClosedCaptions)
- {
- this.media._hideControls = true;
- this.media.controls.y = this.media._controlYhide - this.media.controls.DEFAULT_MAX_HEIGHT * param1;
- this.tree.yfoot = this.media.controls.DEFAULT_MAX_HEIGHT * param1;
- this.media.moveUpdateHandler(new TweenEvent(TweenEvent.TWEEN_UPDATE));
- }
- }
-
- private function FadeEndHandler(param1:Number) : void
- {
- if(param1 < 1 && this.dock == "float")
- {
- this.tree.visible = false;
- }
- if(this.media.config.autoHide && this.media._hasClosedCaptions)
- {
- this.media._hideControls = true;
- this.media.controls.y = this.media._controlYhide - this.media.controls.DEFAULT_MAX_HEIGHT * param1;
- this.tree.yfoot = this.media.controls.DEFAULT_MAX_HEIGHT * param1;
- this.media.moveUpdateHandler(new TweenEvent(TweenEvent.TWEEN_UPDATE));
- }
- }
-
- override protected function updateDisplayList(param1:Number, param2:Number) : void
- {
- setActualSize(param1,param2);
- super.updateDisplayList(param1,param2);
- if(this.dock == "left")
- {
- this.tree.y = 0;
- this.tree.x = this.treepos + 1;
- this.tree.height = param2;
- this.media.x = this.mediapos;
- this.media.width = param1 - this.mediapos;
- this.media.height = param2;
- }
- if(this.dock == "right")
- {
- if(this.lastunscaledWidth != param1)
- {
- if(this.tween)
- {
- this.tween.stop();
- }
- if(this._tocklock)
- {
- this.treepos = param1 - this.tree.width;
- this.mediapos = param1 - this.treepos;
- }
- else
- {
- this.treepos = param1;
- this.mediapos = param1 - this.treepos;
- }
- }
- this.tree.y = 0;
- this.tree.x = this.treepos;
- this.tree.height = param2;
- this.media.x = 0;
- this.media.width = param1 - this.mediapos;
- this.media.height = param2;
- }
- if(this.dock == "float")
- {
- this.media.x = 1;
- this.media.width = param1 - 1;
- this.media.height = param2;
- this.tree.height = param2 - this.media.controls.height >= 400 ? 400 : param2 - this.media.controls.height;
- if(this.tree.y >= param2 - (this.media.controls.height + this.tree.height))
- {
- this.tree.y = param2 - (this.media.controls.height + this.tree.height);
- }
- if(this.tree.y <= 0)
- {
- this.tree.y = 0;
- }
- if(this.lastunscaledWidth != param1 && this.tree.x + this.tree.width >= param1)
- {
- this.tree.x = param1 - (this.tree.width + 5);
- }
- }
- if(this.lastunscaledHeight != param2)
- {
- if(this.media._hasClosedCaptions && !this._tocklock && this.media.config.autoHide)
- {
- this.media.controls.y = param2;
- }
- else
- {
- this.media.controls.y = param2 - this.media.controls.DEFAULT_MAX_HEIGHT;
- }
- }
- this.lastunscaledWidth = param1;
- this.lastunscaledHeight = param2;
- }
-
- public function __tree_creationComplete(param1:FlexEvent) : void
- {
- this.registerlisteners();
- }
-
- [Bindable(event="propertyChange")]
- public function get media() : MediaPlayer
- {
- return this._103772132media;
- }
-
- public function set media(param1:MediaPlayer) : void
- {
- var _loc2_:Object = this._103772132media;
- if(_loc2_ !== param1)
- {
- this._103772132media = param1;
- if(this.hasEventListener("propertyChange"))
- {
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"media",_loc2_,param1));
- }
- }
- }
-
- [Bindable(event="propertyChange")]
- public function get tree() : FloatingToc
- {
- return this._3568542tree;
- }
-
- public function set tree(param1:FloatingToc) : void
- {
- var _loc2_:Object = this._3568542tree;
- if(_loc2_ !== param1)
- {
- this._3568542tree = param1;
- if(this.hasEventListener("propertyChange"))
- {
- this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"tree",_loc2_,param1));
- }
- }
- }
- }
- }
-
-