home *** CD-ROM | disk | FTP | other *** search
/ Leer Poker Spelen / Unibet.iso / content / button.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Encoding:
Text File  |  2007-12-19  |  55.7 KB  |  1,778 lines

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