home *** CD-ROM | disk | FTP | other *** search
/ Canadian Forces: A World of Opportunities / CanadianForces-AWorldOfOpportunities-WinMac.bin / 04_WhatOptions_FR.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Text File  |  2006-07-20  |  57KB  |  1,740 lines

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