home *** CD-ROM | disk | FTP | other *** search
/ Canadian Forces: A World of Opportunities / CanadianForces-AWorldOfOpportunities-WinMac.bin / 04_WhatOptions_FR.swf / scripts / __Packages / mx / video / CuePointManager.as next >
Text File  |  2006-07-20  |  29KB  |  851 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 == undefined || _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 == undefined || 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 == undefined || 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 == undefined || this.asCuePoints.length < 1)
  116.       {
  117.          return null;
  118.       }
  119.       var _loc3_ = undefined;
  120.       switch(typeof timeNameOrCuePoint)
  121.       {
  122.          case "string":
  123.             _loc3_ = {name:timeNameOrCuePoint};
  124.             break;
  125.          case "number":
  126.             _loc3_ = {time:timeNameOrCuePoint};
  127.             break;
  128.          case "object":
  129.             _loc3_ = timeNameOrCuePoint;
  130.       }
  131.       var _loc2_ = this.getCuePointIndex(this.asCuePoints,false,_loc3_.time,_loc3_.name);
  132.       if(_loc2_ < 0)
  133.       {
  134.          return null;
  135.       }
  136.       _loc3_ = this.asCuePoints[_loc2_];
  137.       this.asCuePoints.splice(_loc2_,1);
  138.       _loc2_ = this.getCuePointIndex(this.allCuePoints,false,_loc3_.time,_loc3_.name);
  139.       if(_loc2_ > 0)
  140.       {
  141.          this.allCuePoints.splice(_loc2_,1);
  142.       }
  143.       if(this._owner.getVideoPlayer(this._id).__get__playheadTime() > 0)
  144.       {
  145.          if(this._asCuePointIndex > _loc2_)
  146.          {
  147.             this._asCuePointIndex = this._asCuePointIndex - 1;
  148.          }
  149.       }
  150.       else
  151.       {
  152.          this._asCuePointIndex = 0;
  153.       }
  154.       return _loc3_;
  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 == undefined || _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] == undefined)
  182.                {
  183.                   if(!enabled)
  184.                   {
  185.                      if(this._disabledCuePointsByNameOnly == null || this._disabledCuePointsByNameOnly == undefined || 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 : 1;
  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 == undefined || _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 && this.asCuePoints != undefined)
  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 || this.asCuePoints == undefined)
  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 == undefined || 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_++]) == undefined)
  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.       delete this._disabledCuePointsByNameOnly;
  420.       this._disabledCuePointsByNameOnly = null;
  421.    }
  422.    function processCuePointsProperty(cuePoints)
  423.    {
  424.       if(cuePoints == undefined || cuePoints == null || cuePoints.length == 0)
  425.       {
  426.          return undefined;
  427.       }
  428.       var _loc4_ = 0;
  429.       var _loc8_ = undefined;
  430.       var _loc6_ = undefined;
  431.       var _loc7_ = undefined;
  432.       var _loc5_ = undefined;
  433.       var _loc9_ = undefined;
  434.       var _loc2_ = 0;
  435.       for(; _loc2_ < cuePoints.length - 1; _loc2_ = _loc2_ + 1)
  436.       {
  437.          switch(_loc4_)
  438.          {
  439.             case 6:
  440.                this.addOrDisable(_loc9_,_loc5_);
  441.                _loc4_ = 0;
  442.                break;
  443.             case 0:
  444.                break;
  445.             case 1:
  446.                _loc2_;
  447.                if(cuePoints[_loc2_++] != "n")
  448.                {
  449.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  450.                }
  451.                else
  452.                {
  453.                   if(!(cuePoints[_loc2_] == undefined || cuePoints[_loc2_] == null))
  454.                   {
  455.                      _loc5_.name = this.unescape(cuePoints[_loc2_]);
  456.                      _loc4_ = _loc4_ + 1;
  457.                      continue;
  458.                   }
  459.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be null or undefined");
  460.                }
  461.                break;
  462.             case 2:
  463.                _loc2_;
  464.                if(cuePoints[_loc2_++] != "t")
  465.                {
  466.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  467.                }
  468.                else
  469.                {
  470.                   if(!isNaN(cuePoints[_loc2_]))
  471.                   {
  472.                      switch(cuePoints[_loc2_])
  473.                      {
  474.                         case 0:
  475.                            _loc5_.type = "event";
  476.                            break;
  477.                         case 1:
  478.                            _loc5_.type = "navigation";
  479.                            break;
  480.                         case 2:
  481.                            _loc5_.type = "actionscript";
  482.                            break;
  483.                         default:
  484.                            throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be 0, 1 or 2");
  485.                      }
  486.                      _loc4_ = _loc4_ + 1;
  487.                      continue;
  488.                   }
  489.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be number");
  490.                }
  491.                break;
  492.             case 3:
  493.                _loc2_;
  494.                if(cuePoints[_loc2_++] != "d")
  495.                {
  496.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  497.                }
  498.                else
  499.                {
  500.                   if(!isNaN(cuePoints[_loc2_]))
  501.                   {
  502.                      _loc9_ = cuePoints[_loc2_] != 0;
  503.                      _loc4_ = _loc4_ + 1;
  504.                      continue;
  505.                   }
  506.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"disabled must be number");
  507.                }
  508.                break;
  509.             case 4:
  510.                _loc2_;
  511.                if(cuePoints[_loc2_++] != "p")
  512.                {
  513.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  514.                }
  515.                else
  516.                {
  517.                   if(!isNaN(cuePoints[_loc2_]))
  518.                   {
  519.                      _loc8_ = cuePoints[_loc2_];
  520.                      _loc4_ = _loc4_ + 1;
  521.                      if(_loc8_ == 0)
  522.                      {
  523.                         _loc4_ = _loc4_ + 1;
  524.                      }
  525.                      else
  526.                      {
  527.                         _loc5_.parameters = new Object();
  528.                      }
  529.                      continue;
  530.                   }
  531.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"num params must be number");
  532.                }
  533.                break;
  534.             case 5:
  535.                _loc2_;
  536.                _loc6_ = cuePoints[_loc2_++];
  537.                _loc7_ = cuePoints[_loc2_];
  538.                if(typeof _loc6_ == "string")
  539.                {
  540.                   _loc6_ = this.unescape(_loc6_);
  541.                }
  542.                if(typeof _loc7_ == "string")
  543.                {
  544.                   _loc7_ = this.unescape(_loc7_);
  545.                }
  546.                _loc5_.parameters[_loc6_] = _loc7_;
  547.                _loc8_ = _loc8_ - 1;
  548.                if(_loc8_ == 0)
  549.                {
  550.                   _loc4_ = _loc4_ + 1;
  551.                }
  552.                continue;
  553.             default:
  554.                continue;
  555.          }
  556.          _loc2_;
  557.          if(cuePoints[_loc2_++] != "t")
  558.          {
  559.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  560.          }
  561.          else
  562.          {
  563.             if(!isNaN(cuePoints[_loc2_]))
  564.             {
  565.                _loc5_ = new Object();
  566.                _loc5_.time = cuePoints[_loc2_] / 1000;
  567.                _loc4_ = _loc4_ + 1;
  568.                continue;
  569.             }
  570.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  571.          }
  572.       }
  573.       if(_loc4_ == 6)
  574.       {
  575.          this.addOrDisable(_loc9_,_loc5_);
  576.       }
  577.       throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected end of cuePoint param string");
  578.    }
  579.    function addOrDisable(disable, cuePoint)
  580.    {
  581.       if(disable)
  582.       {
  583.          if(cuePoint.type == "actionscript")
  584.          {
  585.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Cannot disable actionscript cue points");
  586.          }
  587.          else
  588.          {
  589.             this.setFLVCuePointEnabled(false,cuePoint);
  590.          }
  591.       }
  592.       else if(cuePoint.type == "actionscript")
  593.       {
  594.          this.addASCuePoint(cuePoint);
  595.       }
  596.    }
  597.    function unescape(origStr)
  598.    {
  599.       var _loc3_ = origStr;
  600.       var _loc1_ = 0;
  601.       while(_loc1_ < mx.video.CuePointManager.cuePointsReplace.length)
  602.       {
  603.          _loc1_;
  604.          var _loc2_ = _loc3_.split(mx.video.CuePointManager.cuePointsReplace[_loc1_++]);
  605.          if(_loc2_.length > 1)
  606.          {
  607.             _loc3_ = _loc2_.join(mx.video.CuePointManager.cuePointsReplace[_loc1_]);
  608.          }
  609.          _loc1_ = _loc1_ + 1;
  610.       }
  611.       return _loc3_;
  612.    }
  613.    function getCuePointIndex(cuePointArray, closeIsOK, time, name, start, len)
  614.    {
  615.       if(cuePointArray == null || cuePointArray == undefined || cuePointArray.length < 1)
  616.       {
  617.          return -1;
  618.       }
  619.       var _loc13_ = isNaN(time) || time < 0;
  620.       var _loc16_ = name == undefined || name == null;
  621.       if(_loc13_ && _loc16_)
  622.       {
  623.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  624.       }
  625.       else
  626.       {
  627.          if(start == undefined || start == null)
  628.          {
  629.             start = 0;
  630.          }
  631.          if(len == undefined || len == null)
  632.          {
  633.             len = cuePointArray.length;
  634.          }
  635.          if(!_loc16_ && (closeIsOK || _loc13_))
  636.          {
  637.             var _loc8_ = undefined;
  638.             var _loc2_ = undefined;
  639.             if(_loc13_)
  640.             {
  641.                _loc8_ = start;
  642.             }
  643.             else
  644.             {
  645.                _loc8_ = this.getCuePointIndex(cuePointArray,closeIsOK,time);
  646.             }
  647.             _loc2_ = _loc8_;
  648.             while(_loc2_ >= start)
  649.             {
  650.                if(cuePointArray[_loc2_].name == name)
  651.                {
  652.                   break;
  653.                }
  654.                _loc2_ = _loc2_ - 1;
  655.             }
  656.             if(_loc2_ >= start)
  657.             {
  658.                return _loc2_;
  659.             }
  660.             _loc2_ = _loc8_ + 1;
  661.             while(_loc2_ < len)
  662.             {
  663.                if(cuePointArray[_loc2_].name == name)
  664.                {
  665.                   break;
  666.                }
  667.                _loc2_ = _loc2_ + 1;
  668.             }
  669.             if(_loc2_ < len)
  670.             {
  671.                return _loc2_;
  672.             }
  673.             return -1;
  674.          }
  675.          var _loc6_ = undefined;
  676.          if(len <= this._linearSearchTolerance)
  677.          {
  678.             var _loc11_ = start + len;
  679.             var _loc3_ = start;
  680.             while(_loc3_ < _loc11_)
  681.             {
  682.                _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc3_]);
  683.                if(_loc6_ == 0)
  684.                {
  685.                   return _loc3_;
  686.                }
  687.                if(_loc6_ < 0)
  688.                {
  689.                   break;
  690.                }
  691.                _loc3_ = _loc3_ + 1;
  692.             }
  693.             if(closeIsOK)
  694.             {
  695.                if(_loc3_ > 0)
  696.                {
  697.                   return _loc3_ - 1;
  698.                }
  699.                return 0;
  700.             }
  701.             return -1;
  702.          }
  703.          var _loc12_ = Math.floor(len / 2);
  704.          var _loc15_ = start + _loc12_;
  705.          _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc15_]);
  706.          if(_loc6_ < 0)
  707.          {
  708.             return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,start,_loc12_);
  709.          }
  710.          if(_loc6_ > 0)
  711.          {
  712.             return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,_loc15_ + 1,_loc12_ - 1 + len % 2);
  713.          }
  714.          return _loc15_;
  715.       }
  716.    }
  717.    function getNextCuePointIndexWithName(name, array, index)
  718.    {
  719.       if(name == undefined || name == null)
  720.       {
  721.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  722.       }
  723.       else if(array == null || array == undefined)
  724.       {
  725.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.array undefined");
  726.       }
  727.       else if(isNaN(index) || index < -1 || index >= array.length)
  728.       {
  729.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.index must be number between -1 and cuePoint.array.length");
  730.       }
  731.       else
  732.       {
  733.          var _loc1_ = undefined;
  734.          _loc1_ = index + 1;
  735.          while(_loc1_ < array.length)
  736.          {
  737.             if(array[_loc1_].name == name)
  738.             {
  739.                break;
  740.             }
  741.             _loc1_ = _loc1_ + 1;
  742.          }
  743.          if(_loc1_ < array.length)
  744.          {
  745.             return _loc1_;
  746.          }
  747.          return -1;
  748.       }
  749.    }
  750.    static function cuePointCompare(time, name, cuePoint)
  751.    {
  752.       var _loc2_ = Math.round(time * 1000);
  753.       var _loc3_ = Math.round(cuePoint.time * 1000);
  754.       if(_loc2_ < _loc3_)
  755.       {
  756.          return -1;
  757.       }
  758.       if(_loc2_ > _loc3_)
  759.       {
  760.          return 1;
  761.       }
  762.       if(name != null || name != undefined)
  763.       {
  764.          if(name == cuePoint.name)
  765.          {
  766.             return 0;
  767.          }
  768.          if(name < cuePoint.name)
  769.          {
  770.             return -1;
  771.          }
  772.          return 1;
  773.       }
  774.       return 0;
  775.    }
  776.    function getCuePoint(cuePointArray, closeIsOK, timeNameOrCuePoint)
  777.    {
  778.       var _loc3_ = undefined;
  779.       switch(typeof timeNameOrCuePoint)
  780.       {
  781.          case "string":
  782.             _loc3_ = {name:timeNameOrCuePoint};
  783.             break;
  784.          case "number":
  785.             _loc3_ = {time:timeNameOrCuePoint};
  786.             break;
  787.          case "object":
  788.             _loc3_ = timeNameOrCuePoint;
  789.       }
  790.       var _loc2_ = this.getCuePointIndex(cuePointArray,closeIsOK,_loc3_.time,_loc3_.name);
  791.       if(_loc2_ < 0)
  792.       {
  793.          return null;
  794.       }
  795.       _loc3_ = mx.video.CuePointManager.deepCopyObject(cuePointArray[_loc2_]);
  796.       _loc3_.array = cuePointArray;
  797.       _loc3_.index = _loc2_;
  798.       return _loc3_;
  799.    }
  800.    function getNextCuePointWithName(cuePoint)
  801.    {
  802.       if(cuePoint == null || cuePoint == undefined)
  803.       {
  804.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint parameter undefined");
  805.       }
  806.       else if(isNaN(cuePoint.time) || cuePoint.time < 0)
  807.       {
  808.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  809.       }
  810.       else
  811.       {
  812.          var _loc3_ = this.getNextCuePointIndexWithName(cuePoint.name,cuePoint.array,cuePoint.index);
  813.          if(_loc3_ < 0)
  814.          {
  815.             return null;
  816.          }
  817.          var _loc4_ = mx.video.CuePointManager.deepCopyObject(cuePoint.array[_loc3_]);
  818.          _loc4_.array = cuePoint.array;
  819.          _loc4_.index = _loc3_;
  820.          return _loc4_;
  821.       }
  822.    }
  823.    static function deepCopyObject(obj, recurseLevel)
  824.    {
  825.       if(obj == undefined || obj == null || typeof obj != "object")
  826.       {
  827.          return obj;
  828.       }
  829.       if(recurseLevel == undefined)
  830.       {
  831.          recurseLevel = 0;
  832.       }
  833.       var _loc2_ = new Object();
  834.       for(var _loc4_ in obj)
  835.       {
  836.          if(!(recurseLevel == 0 && (_loc4_ == "array" || _loc4_ == "index")))
  837.          {
  838.             if(typeof obj[_loc4_] == "object")
  839.             {
  840.                _loc2_[_loc4_] = mx.video.CuePointManager.deepCopyObject(obj[_loc4_],recurseLevel + 1);
  841.             }
  842.             else
  843.             {
  844.                _loc2_[_loc4_] = obj[_loc4_];
  845.             }
  846.          }
  847.       }
  848.       return _loc2_;
  849.    }
  850. }
  851.