home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / flashVideo / EchoGrove.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Text File  |  2010-12-15  |  59KB  |  1,821 lines

  1. class mx.video.VideoPlayer extends MovieClip
  2. {
  3.    static var version = "1.0.2.7";
  4.    static var shortVersion = "1.0.2";
  5.    static var DISCONNECTED = "disconnected";
  6.    static var STOPPED = "stopped";
  7.    static var PLAYING = "playing";
  8.    static var PAUSED = "paused";
  9.    static var BUFFERING = "buffering";
  10.    static var LOADING = "loading";
  11.    static var CONNECTION_ERROR = "connectionError";
  12.    static var REWINDING = "rewinding";
  13.    static var SEEKING = "seeking";
  14.    static var RESIZING = "resizing";
  15.    static var EXEC_QUEUED_CMD = "execQueuedCmd";
  16.    static var BUFFER_EMPTY = "bufferEmpty";
  17.    static var BUFFER_FULL = "bufferFull";
  18.    static var BUFFER_FLUSH = "bufferFlush";
  19.    static var DEFAULT_INCMANAGER = "mx.video.NCManager";
  20.    static var DEFAULT_UPDATE_TIME_INTERVAL = 250;
  21.    static var DEFAULT_UPDATE_PROGRESS_INTERVAL = 250;
  22.    static var DEFAULT_IDLE_TIMEOUT_INTERVAL = 300000;
  23.    static var AUTO_RESIZE_INTERVAL = 100;
  24.    static var AUTO_RESIZE_PLAYHEAD_TIMEOUT = 0.5;
  25.    static var AUTO_RESIZE_METADATA_DELAY_MAX = 5;
  26.    static var FINISH_AUTO_RESIZE_INTERVAL = 250;
  27.    static var RTMP_DO_STOP_AT_END_INTERVAL = 500;
  28.    static var RTMP_DO_SEEK_INTERVAL = 100;
  29.    static var HTTP_DO_SEEK_INTERVAL = 250;
  30.    static var HTTP_DO_SEEK_MAX_COUNT = 4;
  31.    static var CLOSE_NS_INTERVAL = 0.25;
  32.    static var HTTP_DELAYED_BUFFERING_INTERVAL = 100;
  33.    static var PLAY = 0;
  34.    static var LOAD = 1;
  35.    static var PAUSE = 2;
  36.    static var STOP = 3;
  37.    static var SEEK = 4;
  38.    function VideoPlayer()
  39.    {
  40.       super();
  41.       mx.events.EventDispatcher.initialize(this);
  42.       this._state = mx.video.VideoPlayer.DISCONNECTED;
  43.       this._cachedState = this._state;
  44.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  45.       this._sawPlayStop = false;
  46.       this._cachedPlayheadTime = 0;
  47.       this._metadata = null;
  48.       this._startingPlay = false;
  49.       this._invalidSeekTime = false;
  50.       this._invalidSeekRecovery = false;
  51.       this._currentPos = 0;
  52.       this._atEnd = false;
  53.       this._cmdQueue = new Array();
  54.       this._readyDispatched = false;
  55.       this._autoResizeDone = false;
  56.       this._lastUpdateTime = -1;
  57.       this._sawSeekNotify = false;
  58.       this._updateTimeIntervalID = 0;
  59.       this._updateTimeInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_TIME_INTERVAL;
  60.       this._updateProgressIntervalID = 0;
  61.       this._updateProgressInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_PROGRESS_INTERVAL;
  62.       this._idleTimeoutIntervalID = 0;
  63.       this._idleTimeoutInterval = mx.video.VideoPlayer.DEFAULT_IDLE_TIMEOUT_INTERVAL;
  64.       this._autoResizeIntervalID = 0;
  65.       this._rtmpDoStopAtEndIntervalID = 0;
  66.       this._rtmpDoSeekIntervalID = 0;
  67.       this._httpDoSeekIntervalID = 0;
  68.       this._httpDoSeekCount = 0;
  69.       this._finishAutoResizeIntervalID = 0;
  70.       this._delayedBufferingIntervalID = 0;
  71.       this._delayedBufferingInterval = mx.video.VideoPlayer.HTTP_DELAYED_BUFFERING_INTERVAL;
  72.       if(this._isLive == undefined)
  73.       {
  74.          this._isLive = false;
  75.       }
  76.       if(this._autoSize == undefined)
  77.       {
  78.          this._autoSize = false;
  79.       }
  80.       if(this._aspectRatio == undefined)
  81.       {
  82.          this._aspectRatio = true;
  83.       }
  84.       if(this._autoPlay == undefined)
  85.       {
  86.          this._autoPlay = true;
  87.       }
  88.       if(this._autoRewind == undefined)
  89.       {
  90.          this._autoRewind = true;
  91.       }
  92.       if(this._bufferTime == undefined)
  93.       {
  94.          this._bufferTime = 0.1;
  95.       }
  96.       if(this._volume == undefined)
  97.       {
  98.          this._volume = 100;
  99.       }
  100.       this._sound = new Sound(this);
  101.       this._sound.setVolume(this._volume);
  102.       this.__visible = true;
  103.       this._hiddenForResize = false;
  104.       this._hiddenForResizeMetadataDelay = 0;
  105.       this._contentPath = "";
  106.    }
  107.    function setSize(w, h)
  108.    {
  109.       if(w == this._video._width && h == this._video._height || this._autoSize)
  110.       {
  111.          return undefined;
  112.       }
  113.       this._video._width = w;
  114.       this._video._height = h;
  115.       if(this._aspectRatio)
  116.       {
  117.          this.startAutoResize();
  118.       }
  119.    }
  120.    function setScale(xs, ys)
  121.    {
  122.       if(xs == this._video._xscale && ys == this._video._yscale || this._autoSize)
  123.       {
  124.          return undefined;
  125.       }
  126.       this._video._xscale = xs;
  127.       this._video._yscale = ys;
  128.       if(this._aspectRatio)
  129.       {
  130.          this.startAutoResize();
  131.       }
  132.    }
  133.    function play(url, isLive, totalTime)
  134.    {
  135.       if(url != null)
  136.       {
  137.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  138.          {
  139.             this._state = this._cachedState;
  140.          }
  141.          else
  142.          {
  143.             if(!this.__get__stateResponsive() && this._state != mx.video.VideoPlayer.CONNECTION_ERROR)
  144.             {
  145.                this.queueCmd(mx.video.VideoPlayer.PLAY,url,isLive,totalTime);
  146.                return undefined;
  147.             }
  148.             this.execQueuedCmds();
  149.          }
  150.          this._autoPlay = true;
  151.          this._load(url,isLive,totalTime);
  152.          return undefined;
  153.       }
  154.       if(!this.isXnOK())
  155.       {
  156.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null))
  157.          {
  158.             this.flushQueuedCmds();
  159.             this.queueCmd(mx.video.VideoPlayer.PLAY);
  160.             this.setState(mx.video.VideoPlayer.LOADING);
  161.             this._cachedState = mx.video.VideoPlayer.LOADING;
  162.             this._ncMgr.reconnect();
  163.             return undefined;
  164.          }
  165.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  166.       }
  167.       else
  168.       {
  169.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  170.          {
  171.             this._state = this._cachedState;
  172.          }
  173.          else
  174.          {
  175.             if(!this.__get__stateResponsive())
  176.             {
  177.                this.queueCmd(mx.video.VideoPlayer.PLAY);
  178.                return undefined;
  179.             }
  180.             this.execQueuedCmds();
  181.          }
  182.          if(this._ns == null)
  183.          {
  184.             this._createStream();
  185.             this._video.attachVideo(this._ns);
  186.             this.attachAudio(this._ns);
  187.          }
  188.          switch(this._state)
  189.          {
  190.             case mx.video.VideoPlayer.BUFFERING:
  191.                if(this._ncMgr.isRTMP())
  192.                {
  193.                   this._play(0);
  194.                   if(this._atEnd)
  195.                   {
  196.                      this._atEnd = false;
  197.                      this._currentPos = 0;
  198.                      this.setState(mx.video.VideoPlayer.REWINDING);
  199.                   }
  200.                   else if(this._currentPos > 0)
  201.                   {
  202.                      this._seek(this._currentPos);
  203.                      this._currentPos = 0;
  204.                   }
  205.                }
  206.             case mx.video.VideoPlayer.PLAYING:
  207.                return undefined;
  208.             case mx.video.VideoPlayer.STOPPED:
  209.                if(this._ncMgr.isRTMP())
  210.                {
  211.                   if(this._isLive)
  212.                   {
  213.                      this._play(-1);
  214.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  215.                   }
  216.                   else
  217.                   {
  218.                      this._play(0);
  219.                      if(this._atEnd)
  220.                      {
  221.                         this._atEnd = false;
  222.                         this._currentPos = 0;
  223.                         this._state = mx.video.VideoPlayer.BUFFERING;
  224.                         this.setState(mx.video.VideoPlayer.REWINDING);
  225.                      }
  226.                      else if(this._currentPos > 0)
  227.                      {
  228.                         this._seek(this._currentPos);
  229.                         this._currentPos = 0;
  230.                         this.setState(mx.video.VideoPlayer.BUFFERING);
  231.                      }
  232.                      else
  233.                      {
  234.                         this.setState(mx.video.VideoPlayer.BUFFERING);
  235.                      }
  236.                   }
  237.                }
  238.                else
  239.                {
  240.                   this._pause(false);
  241.                   if(this._atEnd)
  242.                   {
  243.                      this._atEnd = false;
  244.                      this._seek(0);
  245.                      this._state = mx.video.VideoPlayer.BUFFERING;
  246.                      this.setState(mx.video.VideoPlayer.REWINDING);
  247.                   }
  248.                   else if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  249.                   {
  250.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  251.                   }
  252.                   else
  253.                   {
  254.                      this.setState(mx.video.VideoPlayer.PLAYING);
  255.                   }
  256.                }
  257.                break;
  258.             case mx.video.VideoPlayer.PAUSED:
  259.                this._pause(false);
  260.                if(!this._ncMgr.isRTMP())
  261.                {
  262.                   if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  263.                   {
  264.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  265.                   }
  266.                   else
  267.                   {
  268.                      this.setState(mx.video.VideoPlayer.PLAYING);
  269.                   }
  270.                }
  271.                else
  272.                {
  273.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  274.                }
  275.          }
  276.       }
  277.    }
  278.    function load(url, isLive, totalTime)
  279.    {
  280.       if(url == null)
  281.       {
  282.          throw new Error("null url sent to VideoPlayer.load");
  283.       }
  284.       else
  285.       {
  286.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  287.          {
  288.             this._state = this._cachedState;
  289.          }
  290.          else
  291.          {
  292.             if(!this.__get__stateResponsive() && this._state != mx.video.VideoPlayer.CONNECTION_ERROR)
  293.             {
  294.                this.queueCmd(mx.video.VideoPlayer.LOAD,url,isLive,totalTime);
  295.                return undefined;
  296.             }
  297.             this.execQueuedCmds();
  298.          }
  299.          this._autoPlay = false;
  300.          this._load(url,isLive,totalTime);
  301.       }
  302.    }
  303.    function _load(url, isLive, totalTime)
  304.    {
  305.       this._prevVideoWidth = this.videoWidth;
  306.       if(this._prevVideoWidth == undefined)
  307.       {
  308.          this._prevVideoWidth = this._video.width;
  309.          if(this._prevVideoWidth == undefined)
  310.          {
  311.             this._prevVideoWidth = 0;
  312.          }
  313.       }
  314.       this._prevVideoHeight = this.videoHeight;
  315.       if(this._prevVideoHeight == undefined)
  316.       {
  317.          this._prevVideoHeight = this._video.height;
  318.          if(this._prevVideoHeight == undefined)
  319.          {
  320.             this._prevVideoHeight = 0;
  321.          }
  322.       }
  323.       this._autoResizeDone = false;
  324.       this._cachedPlayheadTime = 0;
  325.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  326.       this._sawPlayStop = false;
  327.       this._metadata = null;
  328.       this._startingPlay = false;
  329.       this._invalidSeekTime = false;
  330.       this._invalidSeekRecovery = false;
  331.       this._isLive = isLive != undefined ? isLive : false;
  332.       this._contentPath = url;
  333.       this._currentPos = 0;
  334.       this._streamLength = totalTime;
  335.       this._atEnd = false;
  336.       this._videoWidth = undefined;
  337.       this._videoHeight = undefined;
  338.       this._readyDispatched = false;
  339.       this._lastUpdateTime = -1;
  340.       this._sawSeekNotify = false;
  341.       clearInterval(this._updateTimeIntervalID);
  342.       this._updateTimeIntervalID = 0;
  343.       clearInterval(this._updateProgressIntervalID);
  344.       this._updateProgressIntervalID = 0;
  345.       clearInterval(this._idleTimeoutIntervalID);
  346.       this._idleTimeoutIntervalID = 0;
  347.       clearInterval(this._autoResizeIntervalID);
  348.       this._autoResizeIntervalID = 0;
  349.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  350.       this._rtmpDoStopAtEndIntervalID = 0;
  351.       clearInterval(this._rtmpDoSeekIntervalID);
  352.       this._rtmpDoSeekIntervalID = 0;
  353.       clearInterval(this._httpDoSeekIntervalID);
  354.       this._httpDoSeekIntervalID = 0;
  355.       clearInterval(this._finishAutoResizeIntervalID);
  356.       this._finishAutoResizeIntervalID = 0;
  357.       clearInterval(this._delayedBufferingIntervalID);
  358.       this._delayedBufferingIntervalID = 0;
  359.       this.closeNS(false);
  360.       if(this._ncMgr == null)
  361.       {
  362.          this.createINCManager();
  363.       }
  364.       var _loc2_ = this._ncMgr.connectToURL(this._contentPath);
  365.       this.setState(mx.video.VideoPlayer.LOADING);
  366.       this._cachedState = mx.video.VideoPlayer.LOADING;
  367.       if(_loc2_)
  368.       {
  369.          this._createStream();
  370.          this._setUpStream();
  371.       }
  372.       if(!this._ncMgr.isRTMP())
  373.       {
  374.          clearInterval(this._updateProgressIntervalID);
  375.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  376.       }
  377.    }
  378.    function pause()
  379.    {
  380.       if(!this.isXnOK())
  381.       {
  382.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null))
  383.          {
  384.             return undefined;
  385.          }
  386.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  387.       }
  388.       else
  389.       {
  390.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  391.          {
  392.             this._state = this._cachedState;
  393.          }
  394.          else
  395.          {
  396.             if(!this.__get__stateResponsive())
  397.             {
  398.                this.queueCmd(mx.video.VideoPlayer.PAUSE);
  399.                return undefined;
  400.             }
  401.             this.execQueuedCmds();
  402.          }
  403.          if(this._state == mx.video.VideoPlayer.PAUSED || this._state == mx.video.VideoPlayer.STOPPED || this._ns == null)
  404.          {
  405.             return undefined;
  406.          }
  407.          this._pause(true);
  408.          this.setState(mx.video.VideoPlayer.PAUSED);
  409.       }
  410.    }
  411.    function stop()
  412.    {
  413.       if(!this.isXnOK())
  414.       {
  415.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null))
  416.          {
  417.             return undefined;
  418.          }
  419.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  420.       }
  421.       else
  422.       {
  423.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  424.          {
  425.             this._state = this._cachedState;
  426.          }
  427.          else
  428.          {
  429.             if(!this.__get__stateResponsive())
  430.             {
  431.                this.queueCmd(mx.video.VideoPlayer.STOP);
  432.                return undefined;
  433.             }
  434.             this.execQueuedCmds();
  435.          }
  436.          if(this._state == mx.video.VideoPlayer.STOPPED || this._ns == null)
  437.          {
  438.             return undefined;
  439.          }
  440.          if(this._ncMgr.isRTMP())
  441.          {
  442.             if(this._autoRewind && !this._isLive)
  443.             {
  444.                this._currentPos = 0;
  445.                this._play(0,0);
  446.                this._state = mx.video.VideoPlayer.STOPPED;
  447.                this.setState(mx.video.VideoPlayer.REWINDING);
  448.             }
  449.             else
  450.             {
  451.                this.closeNS(true);
  452.                this.setState(mx.video.VideoPlayer.STOPPED);
  453.             }
  454.          }
  455.          else
  456.          {
  457.             this._pause(true);
  458.             if(this._autoRewind)
  459.             {
  460.                this._seek(0);
  461.                this._state = mx.video.VideoPlayer.STOPPED;
  462.                this.setState(mx.video.VideoPlayer.REWINDING);
  463.             }
  464.             else
  465.             {
  466.                this.setState(mx.video.VideoPlayer.STOPPED);
  467.             }
  468.          }
  469.       }
  470.    }
  471.    function seek(time)
  472.    {
  473.       if(this._invalidSeekTime)
  474.       {
  475.          return undefined;
  476.       }
  477.       if(isNaN(time) || time < 0)
  478.       {
  479.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_SEEK);
  480.       }
  481.       else if(!this.isXnOK())
  482.       {
  483.          if(!(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null))
  484.          {
  485.             this.flushQueuedCmds();
  486.             this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  487.             this.setState(mx.video.VideoPlayer.LOADING);
  488.             this._cachedState = mx.video.VideoPlayer.LOADING;
  489.             this._ncMgr.reconnect();
  490.             return undefined;
  491.          }
  492.          throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  493.       }
  494.       else
  495.       {
  496.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  497.          {
  498.             this._state = this._cachedState;
  499.          }
  500.          else
  501.          {
  502.             if(!this.__get__stateResponsive())
  503.             {
  504.                this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  505.                return undefined;
  506.             }
  507.             this.execQueuedCmds();
  508.          }
  509.          if(this._ns == null)
  510.          {
  511.             this._createStream();
  512.             this._video.attachVideo(this._ns);
  513.             this.attachAudio(this._ns);
  514.          }
  515.          if(this._atEnd && time < this.__get__playheadTime())
  516.          {
  517.             this._atEnd = false;
  518.          }
  519.          switch(this._state)
  520.          {
  521.             case mx.video.VideoPlayer.PLAYING:
  522.                this._state = mx.video.VideoPlayer.BUFFERING;
  523.             case mx.video.VideoPlayer.BUFFERING:
  524.             case mx.video.VideoPlayer.PAUSED:
  525.                this._seek(time);
  526.                this.setState(mx.video.VideoPlayer.SEEKING);
  527.                break;
  528.             case mx.video.VideoPlayer.STOPPED:
  529.                if(this._ncMgr.isRTMP())
  530.                {
  531.                   this._play(0);
  532.                   this._pause(true);
  533.                }
  534.                this._seek(time);
  535.                this._state = mx.video.VideoPlayer.PAUSED;
  536.                this.setState(mx.video.VideoPlayer.SEEKING);
  537.          }
  538.       }
  539.    }
  540.    function close()
  541.    {
  542.       this.closeNS(true);
  543.       if(this._ncMgr != null && this._ncMgr.isRTMP())
  544.       {
  545.          this._ncMgr.close();
  546.       }
  547.       this.setState(mx.video.VideoPlayer.DISCONNECTED);
  548.       this.dispatchEvent({type:"close",state:this._state,playheadTime:this.__get__playheadTime()});
  549.    }
  550.    function get x()
  551.    {
  552.       return this._x;
  553.    }
  554.    function set x(xpos)
  555.    {
  556.       this._x = xpos;
  557.    }
  558.    function get y()
  559.    {
  560.       return this._y;
  561.    }
  562.    function set y(ypos)
  563.    {
  564.       this._y = ypos;
  565.    }
  566.    function get scaleX()
  567.    {
  568.       return this._video._xscale;
  569.    }
  570.    function set scaleX(xs)
  571.    {
  572.       this.setScale(xs,this.__get__scaleY());
  573.    }
  574.    function get scaleY()
  575.    {
  576.       return this._video._yscale;
  577.    }
  578.    function set scaleY(ys)
  579.    {
  580.       this.setScale(this.__get__scaleX(),ys);
  581.    }
  582.    function get width()
  583.    {
  584.       return this._video._width;
  585.    }
  586.    function set width(w)
  587.    {
  588.       this.setSize(w,this._video._height);
  589.    }
  590.    function get height()
  591.    {
  592.       return this._video._height;
  593.    }
  594.    function set height(h)
  595.    {
  596.       this.setSize(this._video._width,h);
  597.    }
  598.    function get videoWidth()
  599.    {
  600.       if(this._readyDispatched)
  601.       {
  602.          this._videoWidth = this._video.width;
  603.       }
  604.       return this._videoWidth;
  605.    }
  606.    function get videoHeight()
  607.    {
  608.       if(this._readyDispatched)
  609.       {
  610.          this._videoHeight = this._video.height;
  611.       }
  612.       return this._videoHeight;
  613.    }
  614.    function get visible()
  615.    {
  616.       if(!this._hiddenForResize)
  617.       {
  618.          this.__visible = this._visible;
  619.       }
  620.       return this.__visible;
  621.    }
  622.    function set visible(v)
  623.    {
  624.       this.__visible = v;
  625.       if(!this._hiddenForResize)
  626.       {
  627.          this._visible = this.__visible;
  628.       }
  629.    }
  630.    function get autoSize()
  631.    {
  632.       return this._autoSize;
  633.    }
  634.    function set autoSize(flag)
  635.    {
  636.       if(this._autoSize != flag)
  637.       {
  638.          this._autoSize = flag;
  639.          if(this._autoSize)
  640.          {
  641.             this.startAutoResize();
  642.          }
  643.       }
  644.    }
  645.    function get maintainAspectRatio()
  646.    {
  647.       return this._aspectRatio;
  648.    }
  649.    function set maintainAspectRatio(flag)
  650.    {
  651.       if(this._aspectRatio != flag)
  652.       {
  653.          this._aspectRatio = flag;
  654.          if(this._aspectRatio && !this._autoSize)
  655.          {
  656.             this.startAutoResize();
  657.          }
  658.       }
  659.    }
  660.    function get autoRewind()
  661.    {
  662.       return this._autoRewind;
  663.    }
  664.    function set autoRewind(flag)
  665.    {
  666.       this._autoRewind = flag;
  667.    }
  668.    function get playheadTime()
  669.    {
  670.       var _loc2_ = this._ns != null ? this._ns.time : this._currentPos;
  671.       if(this._metadata.audiodelay != undefined)
  672.       {
  673.          _loc2_ -= this._metadata.audiodelay;
  674.          if(_loc2_ < 0)
  675.          {
  676.             _loc2_ = 0;
  677.          }
  678.       }
  679.       return _loc2_;
  680.    }
  681.    function set playheadTime(position)
  682.    {
  683.       this.seek(position);
  684.    }
  685.    function get url()
  686.    {
  687.       return this._contentPath;
  688.    }
  689.    function get volume()
  690.    {
  691.       return this._volume;
  692.    }
  693.    function set volume(aVol)
  694.    {
  695.       this._volume = aVol;
  696.       if(!this._hiddenForResize)
  697.       {
  698.          this._sound.setVolume(this._volume);
  699.       }
  700.    }
  701.    function get transform()
  702.    {
  703.       return this._sound.getTransform();
  704.    }
  705.    function set transform(s)
  706.    {
  707.       this._sound.setTransform(s);
  708.    }
  709.    function get isRTMP()
  710.    {
  711.       if(this._ncMgr == null)
  712.       {
  713.          return undefined;
  714.       }
  715.       return this._ncMgr.isRTMP();
  716.    }
  717.    function get isLive()
  718.    {
  719.       return this._isLive;
  720.    }
  721.    function get state()
  722.    {
  723.       return this._state;
  724.    }
  725.    function get stateResponsive()
  726.    {
  727.       switch(this._state)
  728.       {
  729.          case mx.video.VideoPlayer.DISCONNECTED:
  730.          case mx.video.VideoPlayer.STOPPED:
  731.          case mx.video.VideoPlayer.PLAYING:
  732.          case mx.video.VideoPlayer.PAUSED:
  733.          case mx.video.VideoPlayer.BUFFERING:
  734.             return true;
  735.          default:
  736.             return false;
  737.       }
  738.    }
  739.    function get bytesLoaded()
  740.    {
  741.       if(this._ns == null || this._ncMgr.isRTMP())
  742.       {
  743.          return -1;
  744.       }
  745.       return this._ns.bytesLoaded;
  746.    }
  747.    function get bytesTotal()
  748.    {
  749.       if(this._ns == null || this._ncMgr.isRTMP())
  750.       {
  751.          return -1;
  752.       }
  753.       return this._ns.bytesTotal;
  754.    }
  755.    function get totalTime()
  756.    {
  757.       return this._streamLength;
  758.    }
  759.    function get bufferTime()
  760.    {
  761.       return this._bufferTime;
  762.    }
  763.    function set bufferTime(aTime)
  764.    {
  765.       this._bufferTime = aTime;
  766.       if(this._ns != null)
  767.       {
  768.          this._ns.setBufferTime(this._bufferTime);
  769.       }
  770.    }
  771.    function get idleTimeout()
  772.    {
  773.       return this._idleTimeoutInterval;
  774.    }
  775.    function set idleTimeout(aTime)
  776.    {
  777.       this._idleTimeoutInterval = aTime;
  778.       if(this._idleTimeoutIntervalID > 0)
  779.       {
  780.          clearInterval(this._idleTimeoutIntervalID);
  781.          this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  782.       }
  783.    }
  784.    function get playheadUpdateInterval()
  785.    {
  786.       return this._updateTimeInterval;
  787.    }
  788.    function set playheadUpdateInterval(aTime)
  789.    {
  790.       this._updateTimeInterval = aTime;
  791.       if(this._updateTimeIntervalID > 0)
  792.       {
  793.          clearInterval(this._updateTimeIntervalID);
  794.          this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  795.       }
  796.    }
  797.    function get progressInterval()
  798.    {
  799.       return this._updateProgressInterval;
  800.    }
  801.    function set progressInterval(aTime)
  802.    {
  803.       this._updateProgressInterval = aTime;
  804.       if(this._updateProgressIntervalID > 0)
  805.       {
  806.          clearInterval(this._updateProgressIntervalID);
  807.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  808.       }
  809.    }
  810.    function get ncMgr()
  811.    {
  812.       if(this._ncMgr == null)
  813.       {
  814.          this.createINCManager();
  815.       }
  816.       return this._ncMgr;
  817.    }
  818.    function get metadata()
  819.    {
  820.       return this._metadata;
  821.    }
  822.    function doUpdateTime()
  823.    {
  824.       var _loc2_ = this.__get__playheadTime();
  825.       switch(this._state)
  826.       {
  827.          case mx.video.VideoPlayer.STOPPED:
  828.          case mx.video.VideoPlayer.PAUSED:
  829.          case mx.video.VideoPlayer.DISCONNECTED:
  830.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  831.             clearInterval(this._updateTimeIntervalID);
  832.             this._updateTimeIntervalID = 0;
  833.       }
  834.       if(this._lastUpdateTime != _loc2_)
  835.       {
  836.          this.dispatchEvent({type:"playheadUpdate",state:this._state,playheadTime:_loc2_});
  837.          this._lastUpdateTime = _loc2_;
  838.       }
  839.    }
  840.    function doUpdateProgress()
  841.    {
  842.       if(this._ns == null)
  843.       {
  844.          return undefined;
  845.       }
  846.       if(this._ns.bytesTotal >= 0 && this._ns.bytesTotal >= 0)
  847.       {
  848.          this.dispatchEvent({type:"progress",bytesLoaded:this._ns.bytesLoaded,bytesTotal:this._ns.bytesTotal});
  849.       }
  850.       if(this._state == mx.video.VideoPlayer.DISCONNECTED || this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ns.bytesLoaded == this._ns.bytesTotal)
  851.       {
  852.          clearInterval(this._updateProgressIntervalID);
  853.          this._updateProgressIntervalID = 0;
  854.       }
  855.    }
  856.    function rtmpOnStatus(info)
  857.    {
  858.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  859.       {
  860.          return undefined;
  861.       }
  862.       switch(info.code)
  863.       {
  864.          case "NetStream.Play.Stop":
  865.             if(this._startingPlay)
  866.             {
  867.                return undefined;
  868.             }
  869.             switch(this._state)
  870.             {
  871.                case mx.video.VideoPlayer.RESIZING:
  872.                   if(this._hiddenForResize)
  873.                   {
  874.                      this.finishAutoResize();
  875.                   }
  876.                   break;
  877.                case mx.video.VideoPlayer.LOADING:
  878.                case mx.video.VideoPlayer.STOPPED:
  879.                case mx.video.VideoPlayer.PAUSED:
  880.                   break;
  881.                default:
  882.                   this._sawPlayStop = true;
  883.             }
  884.             break;
  885.          case "NetStream.Buffer.Empty":
  886.             if((_loc0_ = this._bufferState) === mx.video.VideoPlayer.BUFFER_FULL)
  887.             {
  888.                if(this._sawPlayStop)
  889.                {
  890.                   this.rtmpDoStopAtEnd(true);
  891.                }
  892.                else if(this._state == mx.video.VideoPlayer.PLAYING)
  893.                {
  894.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  895.                }
  896.             }
  897.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  898.             this._sawPlayStop = false;
  899.             break;
  900.          case "NetStream.Buffer.Flush":
  901.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  902.             {
  903.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  904.                this._sawPlayStop = false;
  905.                this.setStateFromCachedState();
  906.                this.doUpdateTime();
  907.             }
  908.             if(this._sawPlayStop && (this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY || this._bufferTime <= 0.1 && this._ns.bufferLength <= 0.1))
  909.             {
  910.                this._cachedPlayheadTime = this.playheadTime;
  911.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  912.                this._rtmpDoStopAtEndIntervalID = setInterval(this,"rtmpDoStopAtEnd",mx.video.VideoPlayer.RTMP_DO_STOP_AT_END_INTERVAL);
  913.             }
  914.             if((_loc0_ = this._bufferState) !== mx.video.VideoPlayer.BUFFER_EMPTY)
  915.             {
  916.                if(this._state == mx.video.VideoPlayer.BUFFERING)
  917.                {
  918.                   this.setStateFromCachedState();
  919.                }
  920.             }
  921.             else
  922.             {
  923.                if(!this._hiddenForResize)
  924.                {
  925.                   if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  926.                   {
  927.                      this.setState(mx.video.VideoPlayer.PLAYING);
  928.                   }
  929.                   else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  930.                   {
  931.                      this._cachedState = mx.video.VideoPlayer.PLAYING;
  932.                   }
  933.                }
  934.                this._bufferState = mx.video.VideoPlayer.BUFFER_FLUSH;
  935.             }
  936.             break;
  937.          case "NetStream.Buffer.Full":
  938.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  939.             {
  940.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  941.                this._sawPlayStop = false;
  942.                this.setStateFromCachedState();
  943.                this.doUpdateTime();
  944.             }
  945.             switch(this._bufferState)
  946.             {
  947.                case mx.video.VideoPlayer.BUFFER_EMPTY:
  948.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  949.                   if(!this._hiddenForResize)
  950.                   {
  951.                      if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  952.                      {
  953.                         this.setState(mx.video.VideoPlayer.PLAYING);
  954.                      }
  955.                      else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  956.                      {
  957.                         this._cachedState = mx.video.VideoPlayer.PLAYING;
  958.                      }
  959.                      if(this._rtmpDoStopAtEndIntervalID != 0)
  960.                      {
  961.                         this._sawPlayStop = true;
  962.                         clearInterval(this._rtmpDoStopAtEndIntervalID);
  963.                         this._rtmpDoStopAtEndIntervalID = 0;
  964.                      }
  965.                   }
  966.                   break;
  967.                case mx.video.VideoPlayer.BUFFER_FLUSH:
  968.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  969.                   if(this._rtmpDoStopAtEndIntervalID != 0)
  970.                   {
  971.                      this._sawPlayStop = true;
  972.                      clearInterval(this._rtmpDoStopAtEndIntervalID);
  973.                      this._rtmpDoStopAtEndIntervalID = 0;
  974.                   }
  975.             }
  976.             if(this._state == mx.video.VideoPlayer.BUFFERING)
  977.             {
  978.                this.setStateFromCachedState();
  979.             }
  980.             break;
  981.          case "NetStream.Pause.Notify":
  982.             if(this._state == mx.video.VideoPlayer.RESIZING && this._hiddenForResize)
  983.             {
  984.                this.finishAutoResize();
  985.             }
  986.             break;
  987.          case "NetStream.Unpause.Notify":
  988.             if(this._state == mx.video.VideoPlayer.PAUSED)
  989.             {
  990.                this._state = mx.video.VideoPlayer.PLAYING;
  991.                this.setState(mx.video.VideoPlayer.BUFFERING);
  992.             }
  993.             else
  994.             {
  995.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  996.             }
  997.             break;
  998.          case "NetStream.Play.Start":
  999.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1000.             this._rtmpDoStopAtEndIntervalID = 0;
  1001.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1002.             this._sawPlayStop = false;
  1003.             if(this._startingPlay)
  1004.             {
  1005.                this._startingPlay = false;
  1006.                this._cachedPlayheadTime = this.playheadTime;
  1007.             }
  1008.             else if(this._state == mx.video.VideoPlayer.PLAYING)
  1009.             {
  1010.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1011.             }
  1012.             break;
  1013.          case "NetStream.Play.Reset":
  1014.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1015.             this._rtmpDoStopAtEndIntervalID = 0;
  1016.             if(this._state == mx.video.VideoPlayer.REWINDING)
  1017.             {
  1018.                clearInterval(this._rtmpDoSeekIntervalID);
  1019.                this._rtmpDoSeekIntervalID = 0;
  1020.                if(this.__get__playheadTime() == 0 || this.__get__playheadTime() < this._cachedPlayheadTime)
  1021.                {
  1022.                   this.setStateFromCachedState();
  1023.                }
  1024.                else
  1025.                {
  1026.                   this._cachedPlayheadTime = this.playheadTime;
  1027.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1028.                }
  1029.             }
  1030.             break;
  1031.          case "NetStream.Seek.Notify":
  1032.             if(this.__get__playheadTime() != this._cachedPlayheadTime)
  1033.             {
  1034.                this.setStateFromCachedState();
  1035.                this.doUpdateTime();
  1036.             }
  1037.             else
  1038.             {
  1039.                this._sawSeekNotify = true;
  1040.                if(this._rtmpDoSeekIntervalID == 0)
  1041.                {
  1042.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1043.                }
  1044.             }
  1045.             break;
  1046.          case "Netstream.Play.UnpublishNotify":
  1047.             break;
  1048.          case "Netstream.Play.PublishNotify":
  1049.             break;
  1050.          case "NetStream.Play.StreamNotFound":
  1051.             if(!this._ncMgr.connectAgain())
  1052.             {
  1053.                this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1054.             }
  1055.             break;
  1056.          case "NetStream.Play.Failed":
  1057.          case "NetStream.Failed":
  1058.          case "NetStream.Play.FileStructureInvalid":
  1059.          case "NetStream.Play.NoSupportedTrackFound":
  1060.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1061.       }
  1062.    }
  1063.    function httpOnStatus(info)
  1064.    {
  1065.       switch(info.code)
  1066.       {
  1067.          case "NetStream.Play.Stop":
  1068.             clearInterval(this._delayedBufferingIntervalID);
  1069.             this._delayedBufferingIntervalID = 0;
  1070.             if(this._invalidSeekTime)
  1071.             {
  1072.                this._invalidSeekTime = false;
  1073.                this._invalidSeekRecovery = true;
  1074.                this.setState(this._cachedState);
  1075.                this.seek(this.__get__playheadTime());
  1076.             }
  1077.             else
  1078.             {
  1079.                switch(this._state)
  1080.                {
  1081.                   case mx.video.VideoPlayer.SEEKING:
  1082.                      this.httpDoSeek();
  1083.                   case mx.video.VideoPlayer.PLAYING:
  1084.                   case mx.video.VideoPlayer.BUFFERING:
  1085.                      this.httpDoStopAtEnd();
  1086.                }
  1087.             }
  1088.             break;
  1089.          case "NetStream.Seek.InvalidTime":
  1090.             if(this._invalidSeekRecovery)
  1091.             {
  1092.                this._invalidSeekTime = false;
  1093.                this._invalidSeekRecovery = false;
  1094.                this.setState(this._cachedState);
  1095.                this.seek(0);
  1096.             }
  1097.             else
  1098.             {
  1099.                this._invalidSeekTime = true;
  1100.             }
  1101.             break;
  1102.          case "NetStream.Buffer.Empty":
  1103.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1104.             if(this._state == mx.video.VideoPlayer.PLAYING)
  1105.             {
  1106.                clearInterval(this._delayedBufferingIntervalID);
  1107.                this._delayedBufferingIntervalID = setInterval(this,"doDelayedBuffering",this._delayedBufferingInterval);
  1108.             }
  1109.             break;
  1110.          case "NetStream.Buffer.Full":
  1111.          case "NetStream.Buffer.Flush":
  1112.             clearInterval(this._delayedBufferingIntervalID);
  1113.             this._delayedBufferingIntervalID = 0;
  1114.             this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1115.             if(!this._hiddenForResize)
  1116.             {
  1117.                if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  1118.                {
  1119.                   this.setState(mx.video.VideoPlayer.PLAYING);
  1120.                }
  1121.                else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  1122.                {
  1123.                   this._cachedState = mx.video.VideoPlayer.PLAYING;
  1124.                }
  1125.             }
  1126.             break;
  1127.          case "NetStream.Seek.Notify":
  1128.             this._invalidSeekRecovery = false;
  1129.             switch(this._state)
  1130.             {
  1131.                case mx.video.VideoPlayer.SEEKING:
  1132.                case mx.video.VideoPlayer.REWINDING:
  1133.                   if(this._httpDoSeekIntervalID == 0)
  1134.                   {
  1135.                      this._httpDoSeekCount = 0;
  1136.                      this._httpDoSeekIntervalID = setInterval(this,"httpDoSeek",mx.video.VideoPlayer.HTTP_DO_SEEK_INTERVAL);
  1137.                   }
  1138.             }
  1139.             break;
  1140.          case "NetStream.Play.StreamNotFound":
  1141.          case "NetStream.Play.FileStructureInvalid":
  1142.          case "NetStream.Play.NoSupportedTrackFound":
  1143.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1144.       }
  1145.    }
  1146.    function ncConnected()
  1147.    {
  1148.       if(this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  1149.       {
  1150.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1151.       }
  1152.       else if(this._ns == null)
  1153.       {
  1154.          this._createStream();
  1155.          this._setUpStream();
  1156.       }
  1157.    }
  1158.    function ncReconnected()
  1159.    {
  1160.       if(this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  1161.       {
  1162.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1163.       }
  1164.       else
  1165.       {
  1166.          this._ns = null;
  1167.          this._state = mx.video.VideoPlayer.STOPPED;
  1168.          this.execQueuedCmds();
  1169.       }
  1170.    }
  1171.    function onMetaData(info)
  1172.    {
  1173.       if(this._metadata != null)
  1174.       {
  1175.          return undefined;
  1176.       }
  1177.       this._metadata = info;
  1178.       if(this._streamLength == null || this._streamLength <= 0)
  1179.       {
  1180.          this._streamLength = info.duration;
  1181.       }
  1182.       if(isNaN(this._videoWidth) || this._videoWidth <= 0)
  1183.       {
  1184.          this._videoWidth = info.width;
  1185.       }
  1186.       if(isNaN(this._videoHeight) || this._videoHeight <= 0)
  1187.       {
  1188.          this._videoHeight = info.height;
  1189.       }
  1190.       this.dispatchEvent({type:"metadataReceived",info:info});
  1191.    }
  1192.    function onCuePoint(info)
  1193.    {
  1194.       if(!this._hiddenForResize || !isNaN(this._hiddenRewindPlayheadTime) && this.__get__playheadTime() < this._hiddenRewindPlayheadTime)
  1195.       {
  1196.          this.dispatchEvent({type:"cuePoint",info:info});
  1197.       }
  1198.    }
  1199.    function setState(s)
  1200.    {
  1201.       if(s == this._state)
  1202.       {
  1203.          return undefined;
  1204.       }
  1205.       this._hiddenRewindPlayheadTime = undefined;
  1206.       this._cachedState = this._state;
  1207.       this._cachedPlayheadTime = this.playheadTime;
  1208.       this._state = s;
  1209.       var _loc2_ = this._state;
  1210.       this.dispatchEvent({type:"stateChange",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1211.       if(!this._readyDispatched)
  1212.       {
  1213.          switch(_loc2_)
  1214.          {
  1215.             case mx.video.VideoPlayer.STOPPED:
  1216.             case mx.video.VideoPlayer.PLAYING:
  1217.             case mx.video.VideoPlayer.PAUSED:
  1218.             case mx.video.VideoPlayer.BUFFERING:
  1219.                this._readyDispatched = true;
  1220.                this.dispatchEvent({type:"ready",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1221.          }
  1222.       }
  1223.       if((_loc0_ = this._cachedState) === mx.video.VideoPlayer.REWINDING)
  1224.       {
  1225.          this.dispatchEvent({type:"rewind",state:_loc2_,playheadTime:this.__get__playheadTime()});
  1226.          if(this._ncMgr.isRTMP() && _loc2_ == mx.video.VideoPlayer.STOPPED)
  1227.          {
  1228.             this.closeNS();
  1229.          }
  1230.       }
  1231.       switch(_loc2_)
  1232.       {
  1233.          case mx.video.VideoPlayer.STOPPED:
  1234.          case mx.video.VideoPlayer.PAUSED:
  1235.             if(this._ncMgr.isRTMP() && this._idleTimeoutIntervalID == 0)
  1236.             {
  1237.                this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  1238.             }
  1239.             break;
  1240.          case mx.video.VideoPlayer.SEEKING:
  1241.          case mx.video.VideoPlayer.REWINDING:
  1242.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1243.             this._sawPlayStop = false;
  1244.          case mx.video.VideoPlayer.PLAYING:
  1245.          case mx.video.VideoPlayer.BUFFERING:
  1246.             if(this._updateTimeIntervalID == 0)
  1247.             {
  1248.                this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  1249.             }
  1250.          case mx.video.VideoPlayer.LOADING:
  1251.          case mx.video.VideoPlayer.RESIZING:
  1252.             clearInterval(this._idleTimeoutIntervalID);
  1253.             this._idleTimeoutIntervalID = 0;
  1254.       }
  1255.       this.execQueuedCmds();
  1256.    }
  1257.    function setStateFromCachedState()
  1258.    {
  1259.       switch(this._cachedState)
  1260.       {
  1261.          case mx.video.VideoPlayer.PLAYING:
  1262.          case mx.video.VideoPlayer.PAUSED:
  1263.             this.setState(this._cachedState);
  1264.             break;
  1265.          case mx.video.VideoPlayer.BUFFERING:
  1266.             if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  1267.             {
  1268.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1269.             }
  1270.             else
  1271.             {
  1272.                this.setState(this._cachedState);
  1273.             }
  1274.             break;
  1275.          default:
  1276.             this.setState(mx.video.VideoPlayer.STOPPED);
  1277.       }
  1278.    }
  1279.    function createINCManager()
  1280.    {
  1281.       if(this.ncMgrClassName == null)
  1282.       {
  1283.          this.ncMgrClassName = mx.video.VideoPlayer.DEFAULT_INCMANAGER;
  1284.       }
  1285.       var ncMgrConstructor = eval(this.ncMgrClassName);
  1286.       this._ncMgr = new ncMgrConstructor();
  1287.       this._ncMgr.setVideoPlayer(this);
  1288.    }
  1289.    function rtmpDoStopAtEnd(force)
  1290.    {
  1291.       if(this._rtmpDoStopAtEndIntervalID > 0)
  1292.       {
  1293.          switch(this._state)
  1294.          {
  1295.             case mx.video.VideoPlayer.DISCONNECTED:
  1296.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1297.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1298.                this._rtmpDoStopAtEndIntervalID = 0;
  1299.                return undefined;
  1300.             default:
  1301.                if(!(force || this._cachedPlayheadTime == this.__get__playheadTime()))
  1302.                {
  1303.                   this._cachedPlayheadTime = this.playheadTime;
  1304.                   return undefined;
  1305.                }
  1306.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1307.                this._rtmpDoStopAtEndIntervalID = 0;
  1308.          }
  1309.       }
  1310.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1311.       this._sawPlayStop = false;
  1312.       this._atEnd = true;
  1313.       this.setState(mx.video.VideoPlayer.STOPPED);
  1314.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1315.       {
  1316.          return undefined;
  1317.       }
  1318.       this.doUpdateTime();
  1319.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1320.       {
  1321.          return undefined;
  1322.       }
  1323.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.__get__playheadTime()});
  1324.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1325.       {
  1326.          return undefined;
  1327.       }
  1328.       if(this._autoRewind && !this._isLive && this.__get__playheadTime() != 0)
  1329.       {
  1330.          this._atEnd = false;
  1331.          this._currentPos = 0;
  1332.          this._play(0,0);
  1333.          this.setState(mx.video.VideoPlayer.REWINDING);
  1334.       }
  1335.       else
  1336.       {
  1337.          this.closeNS();
  1338.       }
  1339.    }
  1340.    function rtmpDoSeek()
  1341.    {
  1342.       if(this._state != mx.video.VideoPlayer.REWINDING && this._state != mx.video.VideoPlayer.SEEKING)
  1343.       {
  1344.          clearInterval(this._rtmpDoSeekIntervalID);
  1345.          this._rtmpDoSeekIntervalID = 0;
  1346.          this._sawSeekNotify = false;
  1347.       }
  1348.       else if(this.__get__playheadTime() != this._cachedPlayheadTime)
  1349.       {
  1350.          clearInterval(this._rtmpDoSeekIntervalID);
  1351.          this._rtmpDoSeekIntervalID = 0;
  1352.          this._sawSeekNotify = false;
  1353.          this.setStateFromCachedState();
  1354.          this.doUpdateTime();
  1355.       }
  1356.    }
  1357.    function httpDoStopAtEnd()
  1358.    {
  1359.       this._atEnd = true;
  1360.       if(this._streamLength == null || this._streamLength <= 0)
  1361.       {
  1362.          this._streamLength = this._ns.time;
  1363.       }
  1364.       this._pause(true);
  1365.       this.setState(mx.video.VideoPlayer.STOPPED);
  1366.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1367.       {
  1368.          return undefined;
  1369.       }
  1370.       this.doUpdateTime();
  1371.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1372.       {
  1373.          return undefined;
  1374.       }
  1375.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.__get__playheadTime()});
  1376.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1377.       {
  1378.          return undefined;
  1379.       }
  1380.       if(this._autoRewind)
  1381.       {
  1382.          this._atEnd = false;
  1383.          this._pause(true);
  1384.          this._seek(0);
  1385.          this.setState(mx.video.VideoPlayer.REWINDING);
  1386.       }
  1387.    }
  1388.    function httpDoSeek()
  1389.    {
  1390.       var _loc2_ = this._state == mx.video.VideoPlayer.REWINDING || this._state == mx.video.VideoPlayer.SEEKING;
  1391.       if(_loc2_ && this._httpDoSeekCount < mx.video.VideoPlayer.HTTP_DO_SEEK_MAX_COUNT && (this._cachedPlayheadTime == this.__get__playheadTime() || this._invalidSeekTime))
  1392.       {
  1393.          this._httpDoSeekCount = this._httpDoSeekCount + 1;
  1394.          return undefined;
  1395.       }
  1396.       this._httpDoSeekCount = 0;
  1397.       clearInterval(this._httpDoSeekIntervalID);
  1398.       this._httpDoSeekIntervalID = 0;
  1399.       if(!_loc2_)
  1400.       {
  1401.          return undefined;
  1402.       }
  1403.       this.setStateFromCachedState();
  1404.       if(this._invalidSeekTime)
  1405.       {
  1406.          this._invalidSeekTime = false;
  1407.          this._invalidSeekRecovery = true;
  1408.          this.seek(this.__get__playheadTime());
  1409.       }
  1410.       else
  1411.       {
  1412.          this.doUpdateTime();
  1413.       }
  1414.    }
  1415.    function closeNS(updateCurrentPos)
  1416.    {
  1417.       if(this._ns != null && this._ns != undefined)
  1418.       {
  1419.          if(updateCurrentPos)
  1420.          {
  1421.             clearInterval(this._updateTimeIntervalID);
  1422.             this._updateTimeIntervalID = 0;
  1423.             this.doUpdateTime();
  1424.             this._currentPos = this._ns.time;
  1425.          }
  1426.          delete this._ns.onStatus;
  1427.          this._ns.onStatus = null;
  1428.          this._ns.close();
  1429.          this._ns = null;
  1430.       }
  1431.    }
  1432.    function doDelayedBuffering()
  1433.    {
  1434.       switch(this._state)
  1435.       {
  1436.          case mx.video.VideoPlayer.LOADING:
  1437.          case mx.video.VideoPlayer.RESIZING:
  1438.             break;
  1439.          case mx.video.VideoPlayer.PLAYING:
  1440.             clearInterval(this._delayedBufferingIntervalID);
  1441.             this._delayedBufferingIntervalID = 0;
  1442.             this.setState(mx.video.VideoPlayer.BUFFERING);
  1443.             break;
  1444.          default:
  1445.             clearInterval(this._delayedBufferingIntervalID);
  1446.             this._delayedBufferingIntervalID = 0;
  1447.       }
  1448.    }
  1449.    function _pause(doPause)
  1450.    {
  1451.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1452.       this._rtmpDoStopAtEndIntervalID = 0;
  1453.       this._ns.pause(doPause);
  1454.    }
  1455.    function _play()
  1456.    {
  1457.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1458.       this._rtmpDoStopAtEndIntervalID = 0;
  1459.       this._startingPlay = true;
  1460.       switch(arguments.length)
  1461.       {
  1462.          case 0:
  1463.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? 0 : -1,-1);
  1464.             break;
  1465.          case 1:
  1466.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,-1);
  1467.             break;
  1468.          case 2:
  1469.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,arguments[1]);
  1470.             break;
  1471.          default:
  1472.             throw new Error("bad args to _play");
  1473.       }
  1474.    }
  1475.    function _seek(time)
  1476.    {
  1477.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1478.       this._rtmpDoStopAtEndIntervalID = 0;
  1479.       if(this._metadata.audiodelay != undefined && time + this._metadata.audiodelay < this._streamLength)
  1480.       {
  1481.          time += this._metadata.audiodelay;
  1482.       }
  1483.       this._ns.seek(time);
  1484.       this._invalidSeekTime = false;
  1485.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1486.       this._sawPlayStop = false;
  1487.       this._sawSeekNotify = false;
  1488.    }
  1489.    function isXnOK()
  1490.    {
  1491.       if(this._state == mx.video.VideoPlayer.LOADING)
  1492.       {
  1493.          return true;
  1494.       }
  1495.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  1496.       {
  1497.          return false;
  1498.       }
  1499.       if(this._state != mx.video.VideoPlayer.DISCONNECTED)
  1500.       {
  1501.          if(this._ncMgr == null || this._ncMgr.getNetConnection() == null || !this._ncMgr.getNetConnection().isConnected)
  1502.          {
  1503.             this.setState(mx.video.VideoPlayer.DISCONNECTED);
  1504.             return false;
  1505.          }
  1506.          return true;
  1507.       }
  1508.       return false;
  1509.    }
  1510.    function startAutoResize()
  1511.    {
  1512.       switch(this._state)
  1513.       {
  1514.          case mx.video.VideoPlayer.DISCONNECTED:
  1515.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  1516.             return undefined;
  1517.          default:
  1518.             this._autoResizeDone = false;
  1519.             if(this.__get__stateResponsive() && this._videoWidth != undefined && this._videoHeight != undefined)
  1520.             {
  1521.                this.doAutoResize();
  1522.             }
  1523.             else
  1524.             {
  1525.                clearInterval(this._autoResizeIntervalID);
  1526.                this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1527.             }
  1528.       }
  1529.    }
  1530.    function doAutoResize()
  1531.    {
  1532.       if(this._autoResizeIntervalID > 0)
  1533.       {
  1534.          switch(this._state)
  1535.          {
  1536.             case mx.video.VideoPlayer.RESIZING:
  1537.             case mx.video.VideoPlayer.LOADING:
  1538.                break;
  1539.             case mx.video.VideoPlayer.DISCONNECTED:
  1540.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1541.                clearInterval(this._autoResizeIntervalID);
  1542.                this._autoResizeIntervalID = 0;
  1543.                return undefined;
  1544.             default:
  1545.                if(!this.__get__stateResponsive())
  1546.                {
  1547.                   return undefined;
  1548.                }
  1549.                break;
  1550.          }
  1551.          if(!(this._video.width != this._prevVideoWidth || this._video.height != this._prevVideoHeight || this._bufferState == mx.video.VideoPlayer.BUFFER_FULL || this._bufferState == mx.video.VideoPlayer.BUFFER_FLUSH || this._ns.time > mx.video.VideoPlayer.AUTO_RESIZE_PLAYHEAD_TIMEOUT))
  1552.          {
  1553.             return undefined;
  1554.          }
  1555.          if(this._hiddenForResize && this._metadata == null && this._hiddenForResizeMetadataDelay < mx.video.VideoPlayer.AUTO_RESIZE_METADATA_DELAY_MAX)
  1556.          {
  1557.             this._hiddenForResizeMetadataDelay = this._hiddenForResizeMetadataDelay + 1;
  1558.             return undefined;
  1559.          }
  1560.          this._videoWidth = this._video.width;
  1561.          this._videoHeight = this._video.height;
  1562.          clearInterval(this._autoResizeIntervalID);
  1563.          this._autoResizeIntervalID = 0;
  1564.       }
  1565.       if(!this._autoSize && !this._aspectRatio || this._autoResizeDone)
  1566.       {
  1567.          this.setState(this._cachedState);
  1568.          return undefined;
  1569.       }
  1570.       this._autoResizeDone = true;
  1571.       if(this._autoSize)
  1572.       {
  1573.          this._video._width = this._videoWidth;
  1574.          this._video._height = this._videoHeight;
  1575.       }
  1576.       else if(this._aspectRatio)
  1577.       {
  1578.          var _loc3_ = this._videoWidth * this.__get__height() / this._videoHeight;
  1579.          var _loc2_ = this._videoHeight * this.__get__width() / this._videoWidth;
  1580.          if(_loc2_ < this.__get__height())
  1581.          {
  1582.             this._video._height = _loc2_;
  1583.          }
  1584.          else if(_loc3_ < this.__get__width())
  1585.          {
  1586.             this._video._width = _loc3_;
  1587.          }
  1588.       }
  1589.       if(this._hiddenForResize)
  1590.       {
  1591.          this._hiddenRewindPlayheadTime = this.playheadTime;
  1592.          if(this._state == mx.video.VideoPlayer.LOADING)
  1593.          {
  1594.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1595.          }
  1596.          if(!this._ncMgr.isRTMP())
  1597.          {
  1598.             this._pause(true);
  1599.             this._seek(0);
  1600.             clearInterval(this._finishAutoResizeIntervalID);
  1601.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1602.          }
  1603.          else if(!this._isLive)
  1604.          {
  1605.             this._currentPos = 0;
  1606.             this._play(0,0);
  1607.             this.setState(mx.video.VideoPlayer.RESIZING);
  1608.          }
  1609.          else if(this._autoPlay)
  1610.          {
  1611.             clearInterval(this._finishAutoResizeIntervalID);
  1612.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1613.          }
  1614.          else
  1615.          {
  1616.             this.finishAutoResize();
  1617.          }
  1618.       }
  1619.       else
  1620.       {
  1621.          this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1622.       }
  1623.    }
  1624.    function finishAutoResize()
  1625.    {
  1626.       clearInterval(this._finishAutoResizeIntervalID);
  1627.       this._finishAutoResizeIntervalID = 0;
  1628.       if(this.__get__stateResponsive())
  1629.       {
  1630.          return undefined;
  1631.       }
  1632.       this._visible = this.__visible;
  1633.       this._sound.setVolume(this._volume);
  1634.       this._hiddenForResize = false;
  1635.       this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1636.       if(this._autoPlay)
  1637.       {
  1638.          if(this._ncMgr.isRTMP())
  1639.          {
  1640.             if(!this._isLive)
  1641.             {
  1642.                this._currentPos = 0;
  1643.                this._play(0);
  1644.             }
  1645.             if(this._state == mx.video.VideoPlayer.RESIZING)
  1646.             {
  1647.                this.setState(mx.video.VideoPlayer.LOADING);
  1648.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1649.             }
  1650.          }
  1651.          else
  1652.          {
  1653.             this._pause(false);
  1654.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1655.          }
  1656.       }
  1657.       else
  1658.       {
  1659.          this.setState(mx.video.VideoPlayer.STOPPED);
  1660.       }
  1661.    }
  1662.    function _createStream()
  1663.    {
  1664.       this._ns = new NetStream(this._ncMgr.getNetConnection());
  1665.       this._ns.mc = this;
  1666.       if(this._ncMgr.isRTMP())
  1667.       {
  1668.          this._ns.onStatus = function(info)
  1669.          {
  1670.             this.mc.rtmpOnStatus(info);
  1671.          };
  1672.       }
  1673.       else
  1674.       {
  1675.          this._ns.onStatus = function(info)
  1676.          {
  1677.             this.mc.httpOnStatus(info);
  1678.          };
  1679.       }
  1680.       this._ns.onMetaData = function(info)
  1681.       {
  1682.          this.mc.onMetaData(info);
  1683.       };
  1684.       this._ns.onCuePoint = function(info)
  1685.       {
  1686.          this.mc.onCuePoint(info);
  1687.       };
  1688.       this._ns.setBufferTime(this._bufferTime);
  1689.    }
  1690.    function _setUpStream()
  1691.    {
  1692.       this._video.attachVideo(this._ns);
  1693.       this.attachAudio(this._ns);
  1694.       if(!isNaN(this._ncMgr.getStreamLength()) && this._ncMgr.getStreamLength() >= 0)
  1695.       {
  1696.          this._streamLength = this._ncMgr.getStreamLength();
  1697.       }
  1698.       if(!isNaN(this._ncMgr.getStreamWidth()) && this._ncMgr.getStreamWidth() >= 0)
  1699.       {
  1700.          this._videoWidth = this._ncMgr.getStreamWidth();
  1701.       }
  1702.       else
  1703.       {
  1704.          this._videoWidth = undefined;
  1705.       }
  1706.       if(!isNaN(this._ncMgr.getStreamHeight()) && this._ncMgr.getStreamHeight() >= 0)
  1707.       {
  1708.          this._videoHeight = this._ncMgr.getStreamHeight();
  1709.       }
  1710.       else
  1711.       {
  1712.          this._videoHeight = undefined;
  1713.       }
  1714.       if((this._autoSize || this._aspectRatio) && this._videoWidth != undefined && this._videoHeight != undefined)
  1715.       {
  1716.          this._prevVideoWidth = undefined;
  1717.          this._prevVideoHeight = undefined;
  1718.          this.doAutoResize();
  1719.       }
  1720.       if(!this._autoSize && !this._aspectRatio || this._videoWidth != undefined && this._videoHeight != undefined)
  1721.       {
  1722.          if(this._autoPlay)
  1723.          {
  1724.             if(!this._ncMgr.isRTMP())
  1725.             {
  1726.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1727.                this._play();
  1728.             }
  1729.             else if(this._isLive)
  1730.             {
  1731.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1732.                this._play(-1);
  1733.             }
  1734.             else
  1735.             {
  1736.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1737.                this._play(0);
  1738.             }
  1739.          }
  1740.          else
  1741.          {
  1742.             this._cachedState = mx.video.VideoPlayer.STOPPED;
  1743.             if(this._ncMgr.isRTMP())
  1744.             {
  1745.                this._play(0,0);
  1746.             }
  1747.             else
  1748.             {
  1749.                this._play();
  1750.                this._pause(true);
  1751.                this._seek(0);
  1752.             }
  1753.          }
  1754.       }
  1755.       else
  1756.       {
  1757.          if(!this._hiddenForResize)
  1758.          {
  1759.             this.__visible = this._visible;
  1760.             this._visible = false;
  1761.             this._volume = this._sound.getVolume();
  1762.             this._sound.setVolume(0);
  1763.             this._hiddenForResize = true;
  1764.          }
  1765.          this._hiddenForResizeMetadataDelay = 0;
  1766.          this._play(0);
  1767.          if(this._currentPos > 0)
  1768.          {
  1769.             this._seek(this._currentPos);
  1770.             this._currentPos = 0;
  1771.          }
  1772.       }
  1773.       clearInterval(this._autoResizeIntervalID);
  1774.       this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1775.    }
  1776.    function doIdleTimeout()
  1777.    {
  1778.       clearInterval(this._idleTimeoutIntervalID);
  1779.       this._idleTimeoutIntervalID = 0;
  1780.       this.close();
  1781.    }
  1782.    function flushQueuedCmds()
  1783.    {
  1784.       while(this._cmdQueue.length > 0)
  1785.       {
  1786.          this._cmdQueue.pop();
  1787.       }
  1788.    }
  1789.    function execQueuedCmds()
  1790.    {
  1791.       while(this._cmdQueue.length > 0 && (this.__get__stateResponsive() || this._state == mx.video.VideoPlayer.CONNECTION_ERROR) && (this._cmdQueue[0].url != null || this._state != mx.video.VideoPlayer.DISCONNECTED && this._state != mx.video.VideoPlayer.CONNECTION_ERROR))
  1792.       {
  1793.          var _loc2_ = this._cmdQueue.shift();
  1794.          this._cachedState = this._state;
  1795.          this._state = mx.video.VideoPlayer.EXEC_QUEUED_CMD;
  1796.          switch(_loc2_.type)
  1797.          {
  1798.             case mx.video.VideoPlayer.PLAY:
  1799.                this.play(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1800.                break;
  1801.             case mx.video.VideoPlayer.LOAD:
  1802.                this.load(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1803.                break;
  1804.             case mx.video.VideoPlayer.PAUSE:
  1805.                this.pause();
  1806.                break;
  1807.             case mx.video.VideoPlayer.STOP:
  1808.                this.stop();
  1809.                break;
  1810.             case mx.video.VideoPlayer.SEEK:
  1811.                this.seek(_loc2_.time);
  1812.                break;
  1813.          }
  1814.       }
  1815.    }
  1816.    function queueCmd(type, url, isLive, time)
  1817.    {
  1818.       this._cmdQueue.push({type:type,url:url,isLive:isLive,time:time});
  1819.    }
  1820. }
  1821.