home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / pc / t_03.swf / scripts / __Packages / mx / controls / MediaController.as < prev    next >
Encoding:
Text File  |  2005-02-25  |  25.3 KB  |  808 lines

  1. class mx.controls.MediaController extends mx.core.UIComponent
  2. {
  3.    var _lastProgressMediaType;
  4.    var _controllerPolicy;
  5.    var _horizontal;
  6.    var _priorPolicy;
  7.    var _activePlayControl;
  8.    var _backgroundStyle;
  9.    var _isOpen;
  10.    var _priorMouseOver;
  11.    var _closeId;
  12.    var _openId;
  13.    var _isPlaying;
  14.    var _playPercent;
  15.    var _playTime;
  16.    var _volume;
  17.    var playAtBeginning;
  18.    var _screenAccommodator;
  19.    var _playBar;
  20.    var _miniPlayBar;
  21.    var _loadBar;
  22.    var _volumeControl;
  23.    var _buttons;
  24.    var _chrome;
  25.    var _secondChrome;
  26.    var _secondChromeClosedHeight;
  27.    var _secondChromeOpenHeight;
  28.    var _secondChromeClosedWidth;
  29.    var _secondChromeOpenWidth;
  30.    var _secondChromeFixedEnd;
  31.    var _animationStart;
  32.    var _animationOpen;
  33.    var onEnterFrame;
  34.    var _loadPercent;
  35.    var dispatchEvent;
  36.    var _listenForPlayheadMoveEvent;
  37.    var _notAnimating;
  38.    var _strings;
  39.    var _openUpOrLeft;
  40.    static var symbolName = "MediaController";
  41.    static var symbolOwner = mx.controls.MediaController;
  42.    var className = "MediaController";
  43.    static var version = "2.0.1.78";
  44.    var clipParameters = {controllerPolicy:"auto",horizontal:true,activePlayControl:"pause",backgroundStyle:"default"};
  45.    static var MINIMUM_HORIZONTAL_WIDTH = 202;
  46.    static var CLOSED_HORIZONTAL_HEIGHT = 25;
  47.    static var MINIMUM_HORIZONTAL_OPEN_HEIGHT = 63;
  48.    static var LOADBAR_HORIZONTAL_CLOSED_Y = 14;
  49.    static var LOADBAR_HORIZONTAL_OPEN_Y = 24;
  50.    static var MINIMUM_VERTICAL_HEIGHT = 202;
  51.    static var CLOSED_VERTICAL_WIDTH = 25;
  52.    static var MINIMUM_VERTICAL_OPEN_WIDTH = 80;
  53.    static var LOADBAR_VERTICAL_CLOSED_X = 14;
  54.    static var MINIPLAYBAR_VERTICAL_CLOSED_X = 8;
  55.    static var ANIMATION_TIME = 250;
  56.    static var CLOSE_DELAY = 1000;
  57.    static var OPEN_DELAY = 100;
  58.    static var LOCALIZED_FILE = "streamingmediacontroller.xml";
  59.    static var H_BORDER = 8;
  60.    static var V_BORDER = 8;
  61.    var _animating = false;
  62.    var _enabled = true;
  63.    function MediaController()
  64.    {
  65.       super();
  66.    }
  67.    function get lastProgressMediaType()
  68.    {
  69.       return this._lastProgressMediaType;
  70.    }
  71.    function init(Void)
  72.    {
  73.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: start: policy=" + this._controllerPolicy);
  74.       this.initializeParameters();
  75.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after initializeParameters: policy=" + this._controllerPolicy);
  76.       var _loc3_ = this._width;
  77.       var _loc4_ = this._height;
  78.       super.init();
  79.       if(this._horizontal)
  80.       {
  81.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH,_loc3_);
  82.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT,_loc4_);
  83.       }
  84.       else
  85.       {
  86.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH,_loc3_);
  87.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT,_loc4_);
  88.       }
  89.       this.setSize(_loc3_,_loc4_,true);
  90.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after setSize " + this.width + "x" + this.height + " at (" + this._x + "," + this._y + ")");
  91.       this._priorPolicy = this._controllerPolicy;
  92.       this.createDefaultStrings();
  93.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: Initialized properties:");
  94.       mx.controls.streamingmedia.Tracer.trace("  controllerPolicy=" + this._controllerPolicy);
  95.       mx.controls.streamingmedia.Tracer.trace("  horizontal=" + this._horizontal);
  96.       mx.controls.streamingmedia.Tracer.trace("  activePlayControl=" + this._activePlayControl);
  97.       mx.controls.streamingmedia.Tracer.trace("  backgroundStyle=" + this._backgroundStyle);
  98.       if(this._controllerPolicy == "auto")
  99.       {
  100.          this._isOpen = false;
  101.          this._priorMouseOver = false;
  102.          this._closeId = null;
  103.          this._openId = null;
  104.          Mouse.addListener(this);
  105.          this.gotoAndStop(this.getClosedFrameName());
  106.       }
  107.       else if(this._controllerPolicy == "on")
  108.       {
  109.          this._isOpen = true;
  110.          this.gotoAndStop(this.getOpenFrameName());
  111.       }
  112.       else if(this._controllerPolicy == "off")
  113.       {
  114.          this._isOpen = false;
  115.          this.gotoAndStop(this.getClosedFrameName());
  116.       }
  117.       this._isPlaying = this._activePlayControl == "pause";
  118.       this._playPercent = 0;
  119.       this._playTime = 0;
  120.       this._volume = mx.controls.streamingmedia.StreamingMediaConstants.DEFAULT_VOLUME;
  121.       this.setOpenUpOrLeft(false);
  122.       this.setListeningForPlayheadMoveEvent(true);
  123.       this.tabEnabled = false;
  124.       this.tabChildren = true;
  125.       this.playAtBeginning = false;
  126.       this._screenAccommodator = new mx.controls.streamingmedia.ScreenAccommodator(this);
  127.       this.redraw(true);
  128.    }
  129.    function initializeParameters()
  130.    {
  131.       if(this.horizontal == null)
  132.       {
  133.          this.horizontal = true;
  134.       }
  135.       if(this.controllerPolicy == null)
  136.       {
  137.          this.controllerPolicy = "auto";
  138.       }
  139.       if(this.backgroundStyle == null)
  140.       {
  141.          this.backgroundStyle = "default";
  142.       }
  143.       if(this.activePlayControl == null)
  144.       {
  145.          this.activePlayControl = "pause";
  146.       }
  147.    }
  148.    function getOpenFrameName()
  149.    {
  150.       return !this._horizontal ? "openVertical" : "openHorizontal";
  151.    }
  152.    function getClosedFrameName()
  153.    {
  154.       return !this._horizontal ? "closedVertical" : "closedHorizontal";
  155.    }
  156.    function draw(Void)
  157.    {
  158.       if(this._isOpen)
  159.       {
  160.          this.gotoAndStop(this.getOpenFrameName());
  161.          this._playBar.draw();
  162.       }
  163.       else
  164.       {
  165.          this.gotoAndStop(this.getClosedFrameName());
  166.          this._miniPlayBar.draw();
  167.       }
  168.       this._loadBar.draw();
  169.       if(this._horizontal)
  170.       {
  171.          this.positionControlsHorizontal();
  172.       }
  173.       else
  174.       {
  175.          this.positionControlsVertical();
  176.       }
  177.       this.drawChrome();
  178.    }
  179.    function positionControlsVertical()
  180.    {
  181.       if(this._isOpen)
  182.       {
  183.          this._volumeControl._x = (this.width - this._volumeControl._width) / 2;
  184.          this._volumeControl._y = this.height - this._volumeControl._height - 8;
  185.          this._buttons._x = (this.width - this._buttons._width) / 2;
  186.          this._buttons._y = this.height - this._buttons._height - this._volumeControl._height - 16;
  187.          this._playBar._x = (this.width - this._playBar._width) / 2;
  188.          this._loadBar._x = this._playBar._x + this._playBar._width - 4;
  189.       }
  190.       else
  191.       {
  192.          this._loadBar._x = mx.controls.MediaController.LOADBAR_VERTICAL_CLOSED_X;
  193.          this._miniPlayBar._x = mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X;
  194.       }
  195.    }
  196.    function positionControlsHorizontal()
  197.    {
  198.       if(this._isOpen)
  199.       {
  200.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y;
  201.          this._buttons._x = 8;
  202.          this._buttons._y = this.height - this._buttons._height - 8;
  203.          this._volumeControl._x = this.width - this._volumeControl._width - 8;
  204.          this._volumeControl._y = this.height - this._volumeControl._height - 8;
  205.       }
  206.       else
  207.       {
  208.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y;
  209.       }
  210.    }
  211.    function drawChrome(wi, he)
  212.    {
  213.       if(wi == null)
  214.       {
  215.          if(this._horizontal)
  216.          {
  217.             wi = this.width;
  218.          }
  219.          else
  220.          {
  221.             wi = !this._isOpen ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : this.width;
  222.          }
  223.       }
  224.       if(he == null)
  225.       {
  226.          if(this._horizontal)
  227.          {
  228.             he = !this._isOpen ? mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT : this.height;
  229.          }
  230.          else
  231.          {
  232.             he = this.height;
  233.          }
  234.       }
  235.       this._chrome.visible = this.backgroundStyle == "default";
  236.       this._chrome.showToggles = false;
  237.       this._chrome.setSize(wi,he);
  238.       this._chrome.draw();
  239.    }
  240.    function addSecondChrome(theChrome, closedHeight, openHeight, closedWidth, openWidth, fixedEnd)
  241.    {
  242.       this._secondChrome = theChrome;
  243.       this._secondChromeClosedHeight = closedHeight;
  244.       this._secondChromeOpenHeight = openHeight;
  245.       this._secondChromeClosedWidth = closedWidth;
  246.       this._secondChromeOpenWidth = openWidth;
  247.       this._secondChromeFixedEnd = fixedEnd;
  248.    }
  249.    function removeSecondChrome()
  250.    {
  251.       this._secondChrome = null;
  252.    }
  253.    function get expanded()
  254.    {
  255.       return this._isOpen;
  256.    }
  257.    function onMouseMove()
  258.    {
  259.       var _loc5_ = _root._xmouse;
  260.       var _loc4_ = _root._ymouse;
  261.       var _loc3_ = this.hitTest(_loc5_,_loc4_,true);
  262.       if(_loc3_ && this._closeId != null || this.isNotAnimating())
  263.       {
  264.          clearInterval(this._closeId);
  265.          this._closeId = null;
  266.       }
  267.       if(!_loc3_ && this._openId != null || this.isNotAnimating())
  268.       {
  269.          clearInterval(this._openId);
  270.          this._openId = null;
  271.       }
  272.       if(_loc3_ && !this._isOpen && this._controllerPolicy == "auto" && this._openId == null && !this.isNotAnimating())
  273.       {
  274.          this._openId = setInterval(this,"expand",mx.controls.MediaController.OPEN_DELAY);
  275.       }
  276.       else if(!_loc3_ && this._isOpen && this._controllerPolicy == "auto" && this._closeId == null && !this.isNotAnimating())
  277.       {
  278.          this._closeId = setInterval(this,"contract",mx.controls.MediaController.CLOSE_DELAY);
  279.       }
  280.       this._priorMouseOver = _loc3_;
  281.    }
  282.    function expand(force)
  283.    {
  284.       clearInterval(this._openId);
  285.       this._openId = null;
  286.       if(this._controllerPolicy == "auto" || force)
  287.       {
  288.          this._isOpen = true;
  289.          this._animationStart = getTimer();
  290.          this._animationOpen = true;
  291.          this._priorMouseOver = true;
  292.          this.onEnterFrame = this.animate;
  293.       }
  294.    }
  295.    function contract(force)
  296.    {
  297.       mx.controls.streamingmedia.Tracer.trace("MediaController.contract: force=" + force + ", animating=" + this._animating + ", opening=" + this._animationOpen);
  298.       if(this._animating && !this._animationOpen)
  299.       {
  300.          return undefined;
  301.       }
  302.       clearInterval(this._closeId);
  303.       this._closeId = null;
  304.       if(this._controllerPolicy == "auto" || force)
  305.       {
  306.          this._isOpen = false;
  307.          this._animationStart = getTimer();
  308.          this._animationOpen = false;
  309.          this._priorMouseOver = false;
  310.          this.gotoAndStop(this.getClosedFrameName());
  311.          this.animate();
  312.          this.onEnterFrame = this.animate;
  313.       }
  314.    }
  315.    function animate()
  316.    {
  317.       this._animating = true;
  318.       var _loc4_ = getTimer() - this._animationStart;
  319.       var _loc3_ = Math.min(1,_loc4_ / mx.controls.MediaController.ANIMATION_TIME);
  320.       mx.controls.streamingmedia.Tracer.trace("MediaController.animate: _animationStart=" + this._animationStart + ", elapsed=" + _loc4_ + ", portion=" + _loc3_ + ", ANIMATION_TIME=" + mx.controls.MediaController.ANIMATION_TIME);
  321.       this.sizeMainChrome(_loc3_);
  322.       if(this._secondChrome != null)
  323.       {
  324.          this.sizeSecondChrome(_loc3_);
  325.       }
  326.       this.animateBars(_loc3_);
  327.       if(_loc4_ >= mx.controls.MediaController.ANIMATION_TIME || _global.isLivePreview)
  328.       {
  329.          this.animationDone();
  330.       }
  331.    }
  332.    function animationDone()
  333.    {
  334.       mx.controls.streamingmedia.Tracer.trace("MediaController.animationDone");
  335.       this._animating = false;
  336.       delete this.onEnterFrame;
  337.       this.refreshBars();
  338.       if(this._animationOpen)
  339.       {
  340.          this.gotoAndStop(this.getOpenFrameName());
  341.       }
  342.       this.redraw(true);
  343.    }
  344.    function sizeMainChrome(portion)
  345.    {
  346.       var _loc2_ = this.height;
  347.       var _loc3_ = this.width;
  348.       if(this._horizontal)
  349.       {
  350.          var _loc4_ = (this.height - mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT) * portion;
  351.          if(this._animationOpen)
  352.          {
  353.             _loc2_ = mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT + _loc4_;
  354.          }
  355.          else
  356.          {
  357.             _loc2_ = this.height - _loc4_;
  358.          }
  359.       }
  360.       else
  361.       {
  362.          _loc4_ = (this.width - mx.controls.MediaController.CLOSED_VERTICAL_WIDTH) * portion;
  363.          if(this._animationOpen)
  364.          {
  365.             _loc3_ = mx.controls.MediaController.CLOSED_VERTICAL_WIDTH + _loc4_;
  366.          }
  367.          else
  368.          {
  369.             _loc3_ = this.width - _loc4_;
  370.          }
  371.       }
  372.       if(this.isOpenUpOrLeft())
  373.       {
  374.          var _loc6_ = this._chrome.width - _loc3_;
  375.          var _loc5_ = this._chrome.height - _loc2_;
  376.          this._x += _loc6_;
  377.          this._y += _loc5_;
  378.       }
  379.       this.drawChrome(_loc3_,_loc2_);
  380.    }
  381.    function sizeSecondChrome(portion)
  382.    {
  383.       var _loc3_ = undefined;
  384.       var _loc4_ = undefined;
  385.       var _loc2_ = undefined;
  386.       if(this._horizontal)
  387.       {
  388.          _loc4_ = this._secondChromeClosedWidth;
  389.          _loc2_ = (this._secondChromeOpenHeight - this._secondChromeClosedHeight) * portion;
  390.          _loc3_ = !this._animationOpen ? this._secondChromeOpenHeight - _loc2_ : this._secondChromeClosedHeight + _loc2_;
  391.          if(this._secondChromeFixedEnd)
  392.          {
  393.             this._secondChrome._y = this._secondChrome._y - _loc3_ + this._secondChrome.height;
  394.          }
  395.       }
  396.       else
  397.       {
  398.          _loc3_ = this._secondChromeClosedHeight;
  399.          _loc2_ = (this._secondChromeOpenWidth - this._secondChromeClosedWidth) * portion;
  400.          _loc4_ = !this._animationOpen ? this._secondChromeOpenWidth - _loc2_ : this._secondChromeClosedWidth + _loc2_;
  401.          if(this._secondChromeFixedEnd)
  402.          {
  403.             this._secondChrome._x = this._secondChrome._x - _loc4_ + this._secondChrome.width;
  404.          }
  405.       }
  406.       this._secondChrome.setSize(_loc4_,_loc3_);
  407.       this._secondChrome.draw();
  408.    }
  409.    function animateBars(portion)
  410.    {
  411.       var _loc2_ = undefined;
  412.       if(this._horizontal)
  413.       {
  414.          _loc2_ = (mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y) * portion;
  415.          var _loc8_ = !this._animationOpen ? mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - _loc2_ : mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y + _loc2_;
  416.          this._loadBar._y = _loc8_;
  417.       }
  418.       else
  419.       {
  420.          var _loc5_ = this._chrome.width / 2;
  421.          _loc2_ = (_loc5_ - mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X) * portion;
  422.          _loc2_ = Math.max(0,_loc2_);
  423.          var _loc9_ = !this._animationOpen ? _loc5_ - _loc2_ : mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X + _loc2_;
  424.          this._miniPlayBar._x = _loc9_;
  425.          this._loadBar._x = this._miniPlayBar._x + this._miniPlayBar._width;
  426.          var _loc3_ = this._loadBar.getClosedHeight();
  427.          var _loc4_ = this._loadBar.getOpenHeight();
  428.          _loc2_ = (_loc3_ - _loc4_) * portion;
  429.          var _loc6_ = !this._animationOpen ? _loc4_ + _loc2_ : _loc3_ - _loc2_;
  430.          this._loadBar.draw(_loc6_);
  431.          this._miniPlayBar.draw(_loc6_);
  432.       }
  433.    }
  434.    function getLoadBar()
  435.    {
  436.       return this._loadBar;
  437.    }
  438.    function refreshBars()
  439.    {
  440.       mx.controls.streamingmedia.Tracer.trace("MediaController.refreshBars: load=" + this._loadPercent + ", play=" + this._playPercent);
  441.       this._loadBar.setCompletionPercentage(this._loadPercent);
  442.       this._playBar.setCompletionPercentage(this._playPercent);
  443.       this._miniPlayBar.setCompletionPercentage(this._playPercent);
  444.    }
  445.    function getLoadPercent()
  446.    {
  447.       return this._loadPercent;
  448.    }
  449.    function getMinimumOpenHeight()
  450.    {
  451.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT;
  452.       return _loc2_;
  453.    }
  454.    function getMinimumClosedHeight()
  455.    {
  456.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT;
  457.       return _loc2_;
  458.    }
  459.    function getMinimumOpenWidth()
  460.    {
  461.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  462.       return _loc2_;
  463.    }
  464.    function getMinimumClosedWidth()
  465.    {
  466.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  467.       return _loc2_;
  468.    }
  469.    function get controllerPolicy()
  470.    {
  471.       return this._controllerPolicy;
  472.    }
  473.    function set controllerPolicy(aPolicy)
  474.    {
  475.       mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy: old=" + this._controllerPolicy + ", new=" + aPolicy);
  476.       if(aPolicy == this._controllerPolicy)
  477.       {
  478.          return;
  479.       }
  480.       this._controllerPolicy = aPolicy;
  481.       if(this._controllerPolicy == "on")
  482.       {
  483.          Mouse.removeListener(this);
  484.          if(!this._isOpen)
  485.          {
  486.             this.expand(true);
  487.          }
  488.       }
  489.       else if(this._controllerPolicy == "off")
  490.       {
  491.          Mouse.removeListener(this);
  492.          if(this._isOpen)
  493.          {
  494.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(off): about to call contract");
  495.             this.contract(true);
  496.          }
  497.       }
  498.       else if(this._controllerPolicy == "auto")
  499.       {
  500.          this._closeId = null;
  501.          this._openId = null;
  502.          Mouse.addListener(this);
  503.          var _loc3_ = this.hitTest(_root._xmouse,_root._ymouse,true);
  504.          if(this._isOpen && !_loc3_)
  505.          {
  506.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(auto): about to call contract");
  507.             this.contract();
  508.          }
  509.          else if(!this._isOpen && _loc3_)
  510.          {
  511.             this.expand();
  512.          }
  513.       }
  514.    }
  515.    function get horizontal()
  516.    {
  517.       return this._horizontal;
  518.    }
  519.    function set horizontal(isHoriz)
  520.    {
  521.       if(isHoriz != this._horizontal)
  522.       {
  523.          this._horizontal = isHoriz;
  524.          var _loc2_ = this.height;
  525.          var _loc3_ = this.width;
  526.          if(isHoriz)
  527.          {
  528.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH);
  529.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT);
  530.          }
  531.          else
  532.          {
  533.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH);
  534.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT);
  535.          }
  536.          this.setSize(_loc2_,_loc3_);
  537.          this.invalidate();
  538.       }
  539.       else
  540.       {
  541.          this._horizontal = isHoriz;
  542.       }
  543.    }
  544.    function get volume()
  545.    {
  546.       return this._volume;
  547.    }
  548.    function set volume(vol)
  549.    {
  550.       this._volume = vol;
  551.       this._volumeControl.getHandle().setVolume(vol);
  552.    }
  553.    function get backgroundStyle()
  554.    {
  555.       return this._backgroundStyle;
  556.    }
  557.    function set backgroundStyle(aStyle)
  558.    {
  559.       this._backgroundStyle = aStyle;
  560.       this.drawChrome();
  561.    }
  562.    function broadcastEvent(eventType, detailArg)
  563.    {
  564.       var _loc2_ = {type:eventType,target:this,detail:detailArg};
  565.       if(eventType == "volume")
  566.       {
  567.          this._volume = detailArg;
  568.       }
  569.       this.dispatchEvent(_loc2_);
  570.    }
  571.    function handleEvent(ev)
  572.    {
  573.       if(ev.type == "change")
  574.       {
  575.          this.playAtBeginning = false;
  576.          if(this.isListeningForPlayheadMoveEvent())
  577.          {
  578.             this.handleChangeEvent(ev);
  579.          }
  580.       }
  581.       else if(ev.type == "progress")
  582.       {
  583.          this.handleProgressEvent(ev);
  584.       }
  585.       else if(ev.type == "complete")
  586.       {
  587.          this.handleCompleteEvent(ev);
  588.       }
  589.       else if(ev.type == "scrubbing")
  590.       {
  591.          this.handleScrubbingEvent(ev);
  592.       }
  593.       else
  594.       {
  595.          this.handleUnrecognizedEvent(ev);
  596.       }
  597.    }
  598.    function isListeningForPlayheadMoveEvent()
  599.    {
  600.       return this._listenForPlayheadMoveEvent;
  601.    }
  602.    function setListeningForPlayheadMoveEvent(listen)
  603.    {
  604.       this._listenForPlayheadMoveEvent = listen;
  605.    }
  606.    function isNotAnimating()
  607.    {
  608.       return this._notAnimating;
  609.    }
  610.    function setNotAnimating(still)
  611.    {
  612.       this._notAnimating = still;
  613.    }
  614.    function get activePlayControl()
  615.    {
  616.       return this._activePlayControl;
  617.    }
  618.    function set activePlayControl(aControl)
  619.    {
  620.       this._activePlayControl = aControl;
  621.    }
  622.    function get playing()
  623.    {
  624.       return this.isPlaying();
  625.    }
  626.    function set playing(playFlag)
  627.    {
  628.       this.setPlaying(playFlag);
  629.    }
  630.    function isPlaying()
  631.    {
  632.       return this._isPlaying;
  633.    }
  634.    function setPlaying(playFlag)
  635.    {
  636.       this._isPlaying = playFlag;
  637.       this._playBar.setIsPlaying(playFlag);
  638.       if(playFlag)
  639.       {
  640.          this._buttons.playPauseButtons.showPauseButton();
  641.       }
  642.       else
  643.       {
  644.          this._buttons.playPauseButtons.showPlayButton();
  645.       }
  646.    }
  647.    function handleChangeEvent(ev)
  648.    {
  649.       var _loc2_ = ev.target;
  650.       this._playTime = _loc2_.playheadTime;
  651.       var _loc3_ = _loc2_.totalTime;
  652.       this._playPercent = 100 * this._playTime / _loc3_;
  653.       if(this._isOpen)
  654.       {
  655.          this._playBar.setCompletionPercentage(this._playPercent);
  656.          this._playBar.setTime(this._playTime);
  657.       }
  658.       else
  659.       {
  660.          this._miniPlayBar.setCompletionPercentage(this._playPercent);
  661.       }
  662.    }
  663.    function handleProgressEvent(ev)
  664.    {
  665.       if(ev.target.isRtmp(ev.target.contentPath))
  666.       {
  667.          this._loadPercent = 100;
  668.       }
  669.       else
  670.       {
  671.          var _loc4_ = ev.target.bytesLoaded;
  672.          var _loc3_ = ev.target.bytesTotal;
  673.          this._loadPercent = 100 * _loc4_ / _loc3_;
  674.       }
  675.       this.refreshBars();
  676.       this._lastProgressMediaType = ev.target.mediaType;
  677.       this.evaluateToEnd();
  678.    }
  679.    function evaluateToEnd()
  680.    {
  681.       if(!this._isOpen)
  682.       {
  683.          return undefined;
  684.       }
  685.       var _loc2_ = false;
  686.       if(this._loadPercent >= 99 && this.enabled)
  687.       {
  688.          if(this._lastProgressMediaType == "MP3")
  689.          {
  690.             _loc2_ = true;
  691.          }
  692.          else if(this._lastProgressMediaType == "FLV" && !mx.controls.streamingmedia.StreamingMediaConstants.DISABLE_FLV_TOEND)
  693.          {
  694.             _loc2_ = true;
  695.          }
  696.       }
  697.       this._buttons.toEndButton.enabled = _loc2_;
  698.    }
  699.    function handleCompleteEvent(ev)
  700.    {
  701.       if(!this.isScrubbing() && !this._animating)
  702.       {
  703.          var _loc2_ = ev.target;
  704.          this._playTime = _loc2_.totalTime;
  705.          this._playPercent = 100;
  706.          if(this._isOpen)
  707.          {
  708.             this._playBar.setCompletionPercentage(this._playPercent);
  709.             this._playBar.setTime(this._playTime);
  710.          }
  711.          else
  712.          {
  713.             this._miniPlayBar.setCompletionPercentage(this._playPercent);
  714.          }
  715.          this.setPlaying(false);
  716.          mx.controls.streamingmedia.Tracer.trace("MediaController.handleCompleteEvent: playAtBeginning=true");
  717.          this.playAtBeginning = true;
  718.       }
  719.    }
  720.    function handleScrubbingEvent(ev)
  721.    {
  722.       this._listenForPlayheadMoveEvent = !ev.detail;
  723.    }
  724.    function handleUnrecognizedEvent(ev)
  725.    {
  726.       mx.controls.streamingmedia.Tracer.trace("received an unrecognized event of type " + ev.type + " with target " + ev.target);
  727.    }
  728.    function createDefaultStrings()
  729.    {
  730.       this._strings = new Object();
  731.       this._strings.paused = "PAUSED";
  732.       this._strings.streaming = "STREAMING";
  733.    }
  734.    function getLocalizedString(id)
  735.    {
  736.       var _loc2_ = this._strings[id];
  737.       return _loc2_;
  738.    }
  739.    function get playTime()
  740.    {
  741.       return this._playTime;
  742.    }
  743.    function set playTime(aTime)
  744.    {
  745.       this._playTime = aTime;
  746.    }
  747.    function get playPercent()
  748.    {
  749.       return this._playPercent;
  750.    }
  751.    function set playPercent(aPercent)
  752.    {
  753.       this._playPercent = aPercent;
  754.    }
  755.    function isOpenUpOrLeft()
  756.    {
  757.       return this._openUpOrLeft;
  758.    }
  759.    function setOpenUpOrLeft(is)
  760.    {
  761.       this._openUpOrLeft = is;
  762.    }
  763.    function associateDisplay(d)
  764.    {
  765.       d.associateController(this);
  766.    }
  767.    function setSize(w, h, noEvent)
  768.    {
  769.       super.setSize(w,h,noEvent);
  770.       this.invalidate();
  771.    }
  772.    function get enabled()
  773.    {
  774.       return this._enabled;
  775.    }
  776.    function set enabled(is)
  777.    {
  778.       mx.controls.streamingmedia.Tracer.trace("MediaController.set enabled to " + is);
  779.       this._enabled = is;
  780.       this._buttons.toStartButton.enabled = is;
  781.       this._buttons.toEndButton.enabled = is;
  782.       this._buttons.playPauseButtons.enabled = is;
  783.       this._volumeControl._muteButton.muteSimpleButton.enabled = is;
  784.       this._volumeControl._loudButton.loudSimpleButton.enabled = is;
  785.       this._playBar.enabled = is;
  786.       this._volumeControl.getHandle().enabled = is;
  787.       if(is)
  788.       {
  789.          if(this._priorPolicy != null)
  790.          {
  791.             this.controllerPolicy = this._priorPolicy;
  792.          }
  793.       }
  794.       else
  795.       {
  796.          this._priorPolicy = this.controllerPolicy;
  797.          if(this.controllerPolicy == "auto")
  798.          {
  799.             this.controllerPolicy = "off";
  800.          }
  801.       }
  802.    }
  803.    function isScrubbing()
  804.    {
  805.       return this._playBar.isScrubbing();
  806.    }
  807. }
  808.