home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / flashVideo / ArtProject.swf / scripts / __Packages / mx / video / CuePointManager.as next >
Text File  |  2010-12-15  |  28KB  |  849 lines

  1. class mx.video.CuePointManager
  2. {
  3.    static var DEFAULT_LINEAR_SEARCH_TOLERANCE = 50;
  4.    static var cuePointsReplace = [""","\"","'","\'",",",",","&","&"];
  5.    function CuePointManager(owner, id)
  6.    {
  7.       this._owner = owner;
  8.       this._id = id;
  9.       this.reset();
  10.       this._asCuePointTolerance = this._owner.getVideoPlayer(this._id).__get__playheadUpdateInterval() / 2000;
  11.       this._linearSearchTolerance = mx.video.CuePointManager.DEFAULT_LINEAR_SEARCH_TOLERANCE;
  12.    }
  13.    function reset()
  14.    {
  15.       this._metadataLoaded = false;
  16.       this.allCuePoints = null;
  17.       this.asCuePoints = null;
  18.       this._disabledCuePoints = null;
  19.       this.flvCuePoints = null;
  20.       this.navCuePoints = null;
  21.       this.eventCuePoints = null;
  22.       this._asCuePointIndex = 0;
  23.    }
  24.    function get metadataLoaded()
  25.    {
  26.       return this._metadataLoaded;
  27.    }
  28.    function set playheadUpdateInterval(aTime)
  29.    {
  30.       this._asCuePointTolerance = aTime / 2000;
  31.    }
  32.    function get id()
  33.    {
  34.       return this._id;
  35.    }
  36.    function addASCuePoint(timeOrCuePoint, name, parameters)
  37.    {
  38.       var _loc3_ = undefined;
  39.       if(typeof timeOrCuePoint == "object")
  40.       {
  41.          _loc3_ = mx.video.CuePointManager.deepCopyObject(timeOrCuePoint);
  42.       }
  43.       else
  44.       {
  45.          _loc3_ = {time:timeOrCuePoint,name:name,parameters:mx.video.CuePointManager.deepCopyObject(parameters)};
  46.       }
  47.       var _loc7_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  48.       if(_loc7_)
  49.       {
  50.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  51.       }
  52.       else
  53.       {
  54.          var _loc6_ = _loc3_.name == null;
  55.          if(_loc6_)
  56.          {
  57.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  58.          }
  59.          else
  60.          {
  61.             var _loc2_ = undefined;
  62.             _loc3_.type = "actionscript";
  63.             if(this.asCuePoints == null || this.asCuePoints.length < 1)
  64.             {
  65.                _loc2_ = 0;
  66.                this.asCuePoints = new Array();
  67.                this.asCuePoints.push(_loc3_);
  68.             }
  69.             else
  70.             {
  71.                _loc2_ = this.getCuePointIndex(this.asCuePoints,true,_loc3_.time);
  72.                _loc2_ = this.asCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  73.                this.asCuePoints.splice(_loc2_,0,_loc3_);
  74.             }
  75.             if(this.allCuePoints == null || this.allCuePoints.length < 1)
  76.             {
  77.                _loc2_ = 0;
  78.                this.allCuePoints = new Array();
  79.                this.allCuePoints.push(_loc3_);
  80.             }
  81.             else
  82.             {
  83.                _loc2_ = this.getCuePointIndex(this.allCuePoints,true,_loc3_.time);
  84.                _loc2_ = this.allCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  85.                this.allCuePoints.splice(_loc2_,0,_loc3_);
  86.             }
  87.             var _loc5_ = this._owner.getVideoPlayer(this._id).__get__playheadTime();
  88.             if(_loc5_ > 0)
  89.             {
  90.                if(this._asCuePointIndex == _loc2_)
  91.                {
  92.                   if(_loc5_ > this.asCuePoints[_loc2_].time)
  93.                   {
  94.                      this._asCuePointIndex = this._asCuePointIndex + 1;
  95.                   }
  96.                }
  97.                else if(this._asCuePointIndex > _loc2_)
  98.                {
  99.                   this._asCuePointIndex = this._asCuePointIndex + 1;
  100.                }
  101.             }
  102.             else
  103.             {
  104.                this._asCuePointIndex = 0;
  105.             }
  106.             var _loc4_ = mx.video.CuePointManager.deepCopyObject(this.asCuePoints[_loc2_]);
  107.             _loc4_.array = this.asCuePoints;
  108.             _loc4_.index = _loc2_;
  109.             return _loc4_;
  110.          }
  111.       }
  112.    }
  113.    function removeASCuePoint(timeNameOrCuePoint)
  114.    {
  115.       if(this.asCuePoints == null || this.asCuePoints.length < 1)
  116.       {
  117.          return null;
  118.       }
  119.       var _loc2_ = undefined;
  120.       switch(typeof timeNameOrCuePoint)
  121.       {
  122.          case "string":
  123.             _loc2_ = {name:timeNameOrCuePoint};
  124.             break;
  125.          case "number":
  126.             _loc2_ = {time:timeNameOrCuePoint};
  127.             break;
  128.          case "object":
  129.             _loc2_ = timeNameOrCuePoint;
  130.       }
  131.       var _loc3_ = this.getCuePointIndex(this.asCuePoints,false,_loc2_.time,_loc2_.name);
  132.       if(_loc3_ < 0)
  133.       {
  134.          return null;
  135.       }
  136.       _loc2_ = this.asCuePoints[_loc3_];
  137.       this.asCuePoints.splice(_loc3_,1);
  138.       _loc3_ = this.getCuePointIndex(this.allCuePoints,false,_loc2_.time,_loc2_.name);
  139.       if(_loc3_ > 0)
  140.       {
  141.          this.allCuePoints.splice(_loc3_,1);
  142.       }
  143.       if(this._owner.getVideoPlayer(this._id).__get__playheadTime() > 0)
  144.       {
  145.          if(this._asCuePointIndex > _loc3_)
  146.          {
  147.             this._asCuePointIndex = this._asCuePointIndex - 1;
  148.          }
  149.       }
  150.       else
  151.       {
  152.          this._asCuePointIndex = 0;
  153.       }
  154.       return _loc2_;
  155.    }
  156.    function setFLVCuePointEnabled(enabled, timeNameOrCuePoint)
  157.    {
  158.       var _loc4_ = undefined;
  159.       switch(typeof timeNameOrCuePoint)
  160.       {
  161.          case "string":
  162.             _loc4_ = {name:timeNameOrCuePoint};
  163.             break;
  164.          case "number":
  165.             _loc4_ = {time:timeNameOrCuePoint};
  166.             break;
  167.          case "object":
  168.             _loc4_ = timeNameOrCuePoint;
  169.       }
  170.       var _loc12_ = isNaN(_loc4_.time) || _loc4_.time < 0;
  171.       var _loc11_ = _loc4_.name == null;
  172.       if(!(_loc12_ && _loc11_))
  173.       {
  174.          var _loc6_ = 0;
  175.          var _loc2_ = undefined;
  176.          var _loc5_ = undefined;
  177.          if(_loc12_)
  178.          {
  179.             if(!this._metadataLoaded)
  180.             {
  181.                if(this._disabledCuePointsByNameOnly[_loc4_.name] == null)
  182.                {
  183.                   if(!enabled)
  184.                   {
  185.                      if(this._disabledCuePointsByNameOnly == null || this._disabledCuePointsByNameOnly.length < 0)
  186.                      {
  187.                         this._disabledCuePointsByNameOnly = new Object();
  188.                      }
  189.                      this._disabledCuePointsByNameOnly[_loc4_.name] = new Array();
  190.                   }
  191.                   this.removeCuePoints(this._disabledCuePoints,_loc4_);
  192.                   return -1;
  193.                }
  194.                if(enabled)
  195.                {
  196.                   this._disabledCuePointsByNameOnly[_loc4_.name] = undefined;
  197.                }
  198.                return -1;
  199.             }
  200.             if(enabled)
  201.             {
  202.                _loc6_ = this.removeCuePoints(this._disabledCuePoints,_loc4_);
  203.             }
  204.             else
  205.             {
  206.                var _loc3_ = undefined;
  207.                _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc4_.name);
  208.                while(_loc2_ >= 0)
  209.                {
  210.                   _loc3_ = this.flvCuePoints[_loc2_];
  211.                   _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc3_.time);
  212.                   if(_loc5_ < 0 || this._disabledCuePoints[_loc5_].time != _loc3_.time)
  213.                   {
  214.                      this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,{name:_loc3_.name,time:_loc3_.time});
  215.                      _loc6_ += 1;
  216.                   }
  217.                   _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  218.                }
  219.             }
  220.             return _loc6_;
  221.          }
  222.          _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time,_loc4_.name);
  223.          if(_loc2_ < 0)
  224.          {
  225.             if(enabled)
  226.             {
  227.                if(!this._metadataLoaded)
  228.                {
  229.                   _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time);
  230.                   if(_loc2_ < 0)
  231.                   {
  232.                      _loc5_ = this.getCuePointIndex(this._disabledCuePointsByNameOnly[_loc4_.name],true,_loc4_.time);
  233.                      if(mx.video.CuePointManager.cuePointCompare(_loc4_.time,null,this._disabledCuePointsByNameOnly[_loc4_.name]) != 0)
  234.                      {
  235.                         this._disabledCuePointsByNameOnly[_loc4_.name] = this.insertCuePoint(_loc5_,this._disabledCuePointsByNameOnly[_loc4_.name],_loc4_);
  236.                      }
  237.                   }
  238.                   else
  239.                   {
  240.                      this._disabledCuePoints.splice(_loc2_,1);
  241.                   }
  242.                }
  243.                return !this._metadataLoaded ? -1 : 0;
  244.             }
  245.             if(this._metadataLoaded)
  246.             {
  247.                _loc2_ = this.getCuePointIndex(this.flvCuePoints,false,_loc4_.time,_loc4_.name);
  248.                if(_loc2_ < 0)
  249.                {
  250.                   return 0;
  251.                }
  252.                if(_loc11_)
  253.                {
  254.                   _loc4_.name = this.flvCuePoints[_loc2_].name;
  255.                }
  256.             }
  257.             _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc4_.time);
  258.             this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,_loc4_);
  259.             _loc6_ = 1;
  260.             return !this._metadataLoaded ? -1 : _loc6_;
  261.          }
  262.          if(enabled)
  263.          {
  264.             this._disabledCuePoints.splice(_loc2_,1);
  265.             _loc6_ = 1;
  266.          }
  267.          else
  268.          {
  269.             _loc6_ = 0;
  270.          }
  271.          return !this._metadataLoaded ? -1 : _loc6_;
  272.       }
  273.       throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  274.    }
  275.    function removeCuePoints(cuePointArray, cuePoint)
  276.    {
  277.       var _loc2_ = undefined;
  278.       var _loc4_ = undefined;
  279.       var _loc5_ = 0;
  280.       _loc2_ = this.getCuePointIndex(cuePointArray,true,-1,cuePoint.name);
  281.       while(_loc2_ >= 0)
  282.       {
  283.          _loc4_ = cuePointArray[_loc2_];
  284.          cuePointArray.splice(_loc2_,1);
  285.          _loc2_ = _loc2_ - 1;
  286.          _loc5_ = _loc5_ + 1;
  287.          _loc2_ = this.getNextCuePointIndexWithName(_loc4_.name,cuePointArray,_loc2_);
  288.       }
  289.       return _loc5_;
  290.    }
  291.    function insertCuePoint(insertIndex, cuePointArray, cuePoint)
  292.    {
  293.       if(insertIndex < 0)
  294.       {
  295.          cuePointArray = new Array();
  296.          cuePointArray.push(cuePoint);
  297.       }
  298.       else
  299.       {
  300.          if(cuePointArray[insertIndex].time > cuePoint.time)
  301.          {
  302.             insertIndex = 0;
  303.          }
  304.          else
  305.          {
  306.             insertIndex = insertIndex + 1;
  307.          }
  308.          cuePointArray.splice(insertIndex,0,cuePoint);
  309.       }
  310.       return cuePointArray;
  311.    }
  312.    function isFLVCuePointEnabled(timeNameOrCuePoint)
  313.    {
  314.       if(!this._metadataLoaded)
  315.       {
  316.          return true;
  317.       }
  318.       var _loc3_ = undefined;
  319.       switch(typeof timeNameOrCuePoint)
  320.       {
  321.          case "string":
  322.             _loc3_ = {name:timeNameOrCuePoint};
  323.             break;
  324.          case "number":
  325.             _loc3_ = {time:timeNameOrCuePoint};
  326.             break;
  327.          case "object":
  328.             _loc3_ = timeNameOrCuePoint;
  329.       }
  330.       var _loc5_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  331.       var _loc6_ = _loc3_.name == null;
  332.       if(_loc5_ && _loc6_)
  333.       {
  334.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  335.       }
  336.       else
  337.       {
  338.          if(_loc5_)
  339.          {
  340.             var _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc3_.name);
  341.             if(_loc2_ < 0)
  342.             {
  343.                return true;
  344.             }
  345.             while(_loc2_ >= 0)
  346.             {
  347.                if(this.getCuePointIndex(this._disabledCuePoints,false,this.flvCuePoints[_loc2_].time,this.flvCuePoints[_loc2_].name) < 0)
  348.                {
  349.                   return true;
  350.                }
  351.                _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  352.             }
  353.             return false;
  354.          }
  355.          return this.getCuePointIndex(this._disabledCuePoints,false,_loc3_.time,_loc3_.name) < 0;
  356.       }
  357.    }
  358.    function dispatchASCuePoints()
  359.    {
  360.       var _loc5_ = this._owner.getVideoPlayer(this._id).__get__playheadTime();
  361.       if(this._owner.getVideoPlayer(this._id).__get__stateResponsive() && this.asCuePoints != null)
  362.       {
  363.          while(this._asCuePointIndex < this.asCuePoints.length && this.asCuePoints[this._asCuePointIndex].time <= _loc5_ + this._asCuePointTolerance)
  364.          {
  365.             this._owner.dispatchEvent({type:"cuePoint",info:mx.video.CuePointManager.deepCopyObject(this.asCuePoints[this._asCuePointIndex++]),vp:this._id});
  366.          }
  367.       }
  368.    }
  369.    function resetASCuePointIndex(time)
  370.    {
  371.       if(time <= 0 || this.asCuePoints == null)
  372.       {
  373.          this._asCuePointIndex = 0;
  374.          return undefined;
  375.       }
  376.       var _loc2_ = this.getCuePointIndex(this.asCuePoints,true,time);
  377.       this._asCuePointIndex = this.asCuePoints[_loc2_].time >= time ? _loc2_ : _loc2_ + 1;
  378.    }
  379.    function processFLVCuePoints(metadataCuePoints)
  380.    {
  381.       this._metadataLoaded = true;
  382.       if(metadataCuePoints == null || metadataCuePoints.length < 1)
  383.       {
  384.          this.flvCuePoints = null;
  385.          this.navCuePoints = null;
  386.          this.eventCuePoints = null;
  387.          return undefined;
  388.       }
  389.       this.flvCuePoints = metadataCuePoints;
  390.       this.navCuePoints = new Array();
  391.       this.eventCuePoints = new Array();
  392.       var _loc5_ = undefined;
  393.       var _loc6_ = -1;
  394.       var _loc2_ = undefined;
  395.       var _loc4_ = this._disabledCuePoints;
  396.       var _loc3_ = 0;
  397.       this._disabledCuePoints = new Array();
  398.       var _loc9_ = 0;
  399.       while(true)
  400.       {
  401.          _loc9_;
  402.          if((_loc2_ = this.flvCuePoints[_loc9_++]) == null)
  403.          {
  404.             break;
  405.          }
  406.          if(!(_loc6_ > 0 && _loc6_ >= _loc2_.time))
  407.          {
  408.             continue;
  409.          }
  410.          this.flvCuePoints = null;
  411.          this.navCuePoints = null;
  412.          this.eventCuePoints = null;
  413.          this._disabledCuePoints = null;
  414.          this._disabledCuePointsByNameOnly = null;
  415.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Unsorted cuePoint found after time: " + _loc6_);
  416.       }
  417.       delete this._disabledCuePointsByNameOnly;
  418.       this._disabledCuePointsByNameOnly = null;
  419.    }
  420.    function processCuePointsProperty(cuePoints)
  421.    {
  422.       if(cuePoints == null || cuePoints.length == 0)
  423.       {
  424.          return undefined;
  425.       }
  426.       var _loc4_ = 0;
  427.       var _loc8_ = undefined;
  428.       var _loc6_ = undefined;
  429.       var _loc7_ = undefined;
  430.       var _loc5_ = undefined;
  431.       var _loc9_ = undefined;
  432.       var _loc2_ = 0;
  433.       for(; _loc2_ < cuePoints.length - 1; _loc2_ = _loc2_ + 1)
  434.       {
  435.          switch(_loc4_)
  436.          {
  437.             case 6:
  438.                this.addOrDisable(_loc9_,_loc5_);
  439.                _loc4_ = 0;
  440.                break;
  441.             case 0:
  442.                break;
  443.             case 1:
  444.                _loc2_;
  445.                if(cuePoints[_loc2_++] != "n")
  446.                {
  447.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  448.                }
  449.                else
  450.                {
  451.                   if(cuePoints[_loc2_] != null)
  452.                   {
  453.                      _loc5_.name = this.unescape(cuePoints[_loc2_]);
  454.                      _loc4_ = _loc4_ + 1;
  455.                      continue;
  456.                   }
  457.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be null or undefined");
  458.                }
  459.                break;
  460.             case 2:
  461.                _loc2_;
  462.                if(cuePoints[_loc2_++] != "t")
  463.                {
  464.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  465.                }
  466.                else
  467.                {
  468.                   if(!isNaN(cuePoints[_loc2_]))
  469.                   {
  470.                      switch(cuePoints[_loc2_])
  471.                      {
  472.                         case 0:
  473.                            _loc5_.type = "event";
  474.                            break;
  475.                         case 1:
  476.                            _loc5_.type = "navigation";
  477.                            break;
  478.                         case 2:
  479.                            _loc5_.type = "actionscript";
  480.                            break;
  481.                         default:
  482.                            throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be 0, 1 or 2");
  483.                      }
  484.                      _loc4_ = _loc4_ + 1;
  485.                      continue;
  486.                   }
  487.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be number");
  488.                }
  489.                break;
  490.             case 3:
  491.                _loc2_;
  492.                if(cuePoints[_loc2_++] != "d")
  493.                {
  494.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  495.                }
  496.                else
  497.                {
  498.                   if(!isNaN(cuePoints[_loc2_]))
  499.                   {
  500.                      _loc9_ = cuePoints[_loc2_] != 0;
  501.                      _loc4_ = _loc4_ + 1;
  502.                      continue;
  503.                   }
  504.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"disabled must be number");
  505.                }
  506.                break;
  507.             case 4:
  508.                _loc2_;
  509.                if(cuePoints[_loc2_++] != "p")
  510.                {
  511.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  512.                }
  513.                else
  514.                {
  515.                   if(!isNaN(cuePoints[_loc2_]))
  516.                   {
  517.                      _loc8_ = cuePoints[_loc2_];
  518.                      _loc4_ = _loc4_ + 1;
  519.                      if(_loc8_ == 0)
  520.                      {
  521.                         _loc4_ = _loc4_ + 1;
  522.                      }
  523.                      else
  524.                      {
  525.                         _loc5_.parameters = new Object();
  526.                      }
  527.                      continue;
  528.                   }
  529.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"num params must be number");
  530.                }
  531.                break;
  532.             case 5:
  533.                _loc2_;
  534.                _loc6_ = cuePoints[_loc2_++];
  535.                _loc7_ = cuePoints[_loc2_];
  536.                if(typeof _loc6_ == "string")
  537.                {
  538.                   _loc6_ = this.unescape(_loc6_);
  539.                }
  540.                if(typeof _loc7_ == "string")
  541.                {
  542.                   _loc7_ = this.unescape(_loc7_);
  543.                }
  544.                _loc5_.parameters[_loc6_] = _loc7_;
  545.                _loc8_ = _loc8_ - 1;
  546.                if(_loc8_ == 0)
  547.                {
  548.                   _loc4_ = _loc4_ + 1;
  549.                }
  550.                continue;
  551.             default:
  552.                continue;
  553.          }
  554.          _loc2_;
  555.          if(cuePoints[_loc2_++] != "t")
  556.          {
  557.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  558.          }
  559.          else
  560.          {
  561.             if(!isNaN(cuePoints[_loc2_]))
  562.             {
  563.                _loc5_ = new Object();
  564.                _loc5_.time = cuePoints[_loc2_] / 1000;
  565.                _loc4_ = _loc4_ + 1;
  566.                continue;
  567.             }
  568.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  569.          }
  570.       }
  571.       if(_loc4_ == 6)
  572.       {
  573.          this.addOrDisable(_loc9_,_loc5_);
  574.       }
  575.       throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected end of cuePoint param string");
  576.    }
  577.    function addOrDisable(disable, cuePoint)
  578.    {
  579.       if(disable)
  580.       {
  581.          if(cuePoint.type == "actionscript")
  582.          {
  583.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Cannot disable actionscript cue points");
  584.          }
  585.          else
  586.          {
  587.             this.setFLVCuePointEnabled(false,cuePoint);
  588.          }
  589.       }
  590.       else if(cuePoint.type == "actionscript")
  591.       {
  592.          this.addASCuePoint(cuePoint);
  593.       }
  594.    }
  595.    function unescape(origStr)
  596.    {
  597.       var _loc3_ = origStr;
  598.       var _loc1_ = 0;
  599.       while(_loc1_ < mx.video.CuePointManager.cuePointsReplace.length)
  600.       {
  601.          _loc1_;
  602.          var _loc2_ = _loc3_.split(mx.video.CuePointManager.cuePointsReplace[_loc1_++]);
  603.          if(_loc2_.length > 1)
  604.          {
  605.             _loc3_ = _loc2_.join(mx.video.CuePointManager.cuePointsReplace[_loc1_]);
  606.          }
  607.          _loc1_ = _loc1_ + 1;
  608.       }
  609.       return _loc3_;
  610.    }
  611.    function getCuePointIndex(cuePointArray, closeIsOK, time, name, start, len)
  612.    {
  613.       if(cuePointArray == null || cuePointArray.length < 1)
  614.       {
  615.          return -1;
  616.       }
  617.       var _loc13_ = isNaN(time) || time < 0;
  618.       var _loc16_ = name == null;
  619.       if(_loc13_ && _loc16_)
  620.       {
  621.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  622.       }
  623.       else
  624.       {
  625.          if(start == null)
  626.          {
  627.             start = 0;
  628.          }
  629.          if(len == null)
  630.          {
  631.             len = cuePointArray.length;
  632.          }
  633.          if(!_loc16_ && (closeIsOK || _loc13_))
  634.          {
  635.             var _loc8_ = undefined;
  636.             var _loc2_ = undefined;
  637.             if(_loc13_)
  638.             {
  639.                _loc8_ = start;
  640.             }
  641.             else
  642.             {
  643.                _loc8_ = this.getCuePointIndex(cuePointArray,closeIsOK,time);
  644.             }
  645.             _loc2_ = _loc8_;
  646.             while(_loc2_ >= start)
  647.             {
  648.                if(cuePointArray[_loc2_].name == name)
  649.                {
  650.                   break;
  651.                }
  652.                _loc2_ = _loc2_ - 1;
  653.             }
  654.             if(_loc2_ >= start)
  655.             {
  656.                return _loc2_;
  657.             }
  658.             _loc2_ = _loc8_ + 1;
  659.             while(_loc2_ < len)
  660.             {
  661.                if(cuePointArray[_loc2_].name == name)
  662.                {
  663.                   break;
  664.                }
  665.                _loc2_ = _loc2_ + 1;
  666.             }
  667.             if(_loc2_ < len)
  668.             {
  669.                return _loc2_;
  670.             }
  671.             return -1;
  672.          }
  673.          var _loc6_ = undefined;
  674.          if(len <= this._linearSearchTolerance)
  675.          {
  676.             var _loc11_ = start + len;
  677.             var _loc3_ = start;
  678.             while(_loc3_ < _loc11_)
  679.             {
  680.                _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc3_]);
  681.                if(_loc6_ == 0)
  682.                {
  683.                   return _loc3_;
  684.                }
  685.                if(_loc6_ < 0)
  686.                {
  687.                   break;
  688.                }
  689.                _loc3_ = _loc3_ + 1;
  690.             }
  691.             if(closeIsOK)
  692.             {
  693.                if(_loc3_ > 0)
  694.                {
  695.                   return _loc3_ - 1;
  696.                }
  697.                return 0;
  698.             }
  699.             return -1;
  700.          }
  701.          var _loc12_ = Math.floor(len / 2);
  702.          var _loc15_ = start + _loc12_;
  703.          _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc15_]);
  704.          if(_loc6_ < 0)
  705.          {
  706.             return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,start,_loc12_);
  707.          }
  708.          if(_loc6_ > 0)
  709.          {
  710.             return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,_loc15_ + 1,_loc12_ - 1 + len % 2);
  711.          }
  712.          return _loc15_;
  713.       }
  714.    }
  715.    function getNextCuePointIndexWithName(name, array, index)
  716.    {
  717.       if(name == null)
  718.       {
  719.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  720.       }
  721.       else if(array == null)
  722.       {
  723.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.array undefined");
  724.       }
  725.       else if(isNaN(index) || index < -1 || index >= array.length)
  726.       {
  727.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.index must be number between -1 and cuePoint.array.length");
  728.       }
  729.       else
  730.       {
  731.          var _loc1_ = undefined;
  732.          _loc1_ = index + 1;
  733.          while(_loc1_ < array.length)
  734.          {
  735.             if(array[_loc1_].name == name)
  736.             {
  737.                break;
  738.             }
  739.             _loc1_ = _loc1_ + 1;
  740.          }
  741.          if(_loc1_ < array.length)
  742.          {
  743.             return _loc1_;
  744.          }
  745.          return -1;
  746.       }
  747.    }
  748.    static function cuePointCompare(time, name, cuePoint)
  749.    {
  750.       var _loc1_ = Math.round(time * 1000);
  751.       var _loc2_ = Math.round(cuePoint.time * 1000);
  752.       if(_loc1_ < _loc2_)
  753.       {
  754.          return -1;
  755.       }
  756.       if(_loc1_ > _loc2_)
  757.       {
  758.          return 1;
  759.       }
  760.       if(name != null)
  761.       {
  762.          if(name == cuePoint.name)
  763.          {
  764.             return 0;
  765.          }
  766.          if(name < cuePoint.name)
  767.          {
  768.             return -1;
  769.          }
  770.          return 1;
  771.       }
  772.       return 0;
  773.    }
  774.    function getCuePoint(cuePointArray, closeIsOK, timeNameOrCuePoint)
  775.    {
  776.       var _loc2_ = undefined;
  777.       switch(typeof timeNameOrCuePoint)
  778.       {
  779.          case "string":
  780.             _loc2_ = {name:timeNameOrCuePoint};
  781.             break;
  782.          case "number":
  783.             _loc2_ = {time:timeNameOrCuePoint};
  784.             break;
  785.          case "object":
  786.             _loc2_ = timeNameOrCuePoint;
  787.       }
  788.       var _loc3_ = this.getCuePointIndex(cuePointArray,closeIsOK,_loc2_.time,_loc2_.name);
  789.       if(_loc3_ < 0)
  790.       {
  791.          return null;
  792.       }
  793.       _loc2_ = mx.video.CuePointManager.deepCopyObject(cuePointArray[_loc3_]);
  794.       _loc2_.array = cuePointArray;
  795.       _loc2_.index = _loc3_;
  796.       return _loc2_;
  797.    }
  798.    function getNextCuePointWithName(cuePoint)
  799.    {
  800.       if(cuePoint == null)
  801.       {
  802.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint parameter undefined");
  803.       }
  804.       else if(isNaN(cuePoint.time) || cuePoint.time < 0)
  805.       {
  806.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  807.       }
  808.       else
  809.       {
  810.          var _loc3_ = this.getNextCuePointIndexWithName(cuePoint.name,cuePoint.array,cuePoint.index);
  811.          if(_loc3_ < 0)
  812.          {
  813.             return null;
  814.          }
  815.          var _loc4_ = mx.video.CuePointManager.deepCopyObject(cuePoint.array[_loc3_]);
  816.          _loc4_.array = cuePoint.array;
  817.          _loc4_.index = _loc3_;
  818.          return _loc4_;
  819.       }
  820.    }
  821.    static function deepCopyObject(obj, recurseLevel)
  822.    {
  823.       if(obj == null || typeof obj != "object")
  824.       {
  825.          return obj;
  826.       }
  827.       if(recurseLevel == null)
  828.       {
  829.          recurseLevel = 0;
  830.       }
  831.       var _loc2_ = new Object();
  832.       for(var _loc4_ in obj)
  833.       {
  834.          if(!(recurseLevel == 0 && (_loc4_ == "array" || _loc4_ == "index")))
  835.          {
  836.             if(typeof obj[_loc4_] == "object")
  837.             {
  838.                _loc2_[_loc4_] = mx.video.CuePointManager.deepCopyObject(obj[_loc4_],recurseLevel + 1);
  839.             }
  840.             else
  841.             {
  842.                _loc2_[_loc4_] = obj[_loc4_];
  843.             }
  844.          }
  845.       }
  846.       return _loc2_;
  847.    }
  848. }
  849.