loadSegment_(segmentInfo) {
    let segment;
    let keyXhr;
    let initSegmentXhr;
    let segmentXhr;
    let removeToTime = 0;

    removeToTime = this.trimBuffer_(segmentInfo);

    if (removeToTime > 0) {
      this.sourceUpdater_.remove(0, removeToTime);
    }

    segment = segmentInfo.playlist.segments[segmentInfo.mediaIndex];

    // optionally, request the decryption key
    // 可选地，请求解密密钥
    if (segment.key) {

      if(localStorage[segment.key.uri]){
        let localKeyString = localStorage[segment.key.uri];
        let localKeyArray = [];
        for(let j=0;j<4;j++){
          localKeyArray.push(parseInt(localKeyString.substr(10*j,10)));
        }
        segment.key.bytes=localKeyArray;
      }else{
        let keyRequestOptions = videojs.mergeOptions(this.xhrOptions_, {
          uri: segment.key.resolvedUri,
          //responseType: 'arraybuffer'
        });

        keyXhr = this.hls_.xhr(keyRequestOptions, this.handleResponse_.bind(this));
      }
    }

    // optionally, request the associated media init segment
    // 可选地，请求关联媒体init段
    if (segment.map &&
        !this.initSegments_[initSegmentId(segment.map)]) {
      let initSegmentOptions = videojs.mergeOptions(this.xhrOptions_, {
        uri: segment.map.resolvedUri,
        responseType: 'arraybuffer',
        headers: segmentXhrHeaders(segment.map)
      });

      initSegmentXhr = this.hls_.xhr(initSegmentOptions,
                                     this.handleResponse_.bind(this));
    }
    this.pendingSegment_ = segmentInfo;

    let segmentRequestOptions = videojs.mergeOptions(this.xhrOptions_, {
      uri: segmentInfo.uri,
      responseType: 'arraybuffer',
      headers: segmentXhrHeaders(segment)
    });

    segmentXhr = this.hls_.xhr(segmentRequestOptions, this.handleResponse_.bind(this));

    this.xhr_ = {
      keyXhr,
      initSegmentXhr,
      segmentXhr,
      abort() {
        if (this.segmentXhr) {
          // Prevent error handler from running.
          this.segmentXhr.onreadystatechange = null;
          this.segmentXhr.abort();
          this.segmentXhr = null;
        }
        if (this.initSegmentXhr) {
          // Prevent error handler from running.
          this.initSegmentXhr.onreadystatechange = null;
          this.initSegmentXhr.abort();
          this.initSegmentXhr = null;
        }
        if (this.keyXhr) {
          // Prevent error handler from running.
          this.keyXhr.onreadystatechange = null;
          this.keyXhr.abort();
          this.keyXhr = null;
        }
      }
    };

    this.state = 'WAITING';
  }
/**
   * load a specific segment from a request into the buffer
   *
   * @private
   */
load a specific segment from a request into the buffer
@private
load a specific segment from a request into the buffer @private
loadSegment_(segmentInfo) {
    let segment;
    let keyXhr;
    let initSegmentXhr;
    let segmentXhr;
    let removeToTime = 0;
    removeToTime = this.trimBuffer_(segmentInfo);
    if (removeToTime > 0) {
      this.sourceUpdater_.remove(0, removeToTime);
    }
    segment = segmentInfo.playlist.segments[segmentInfo.mediaIndex];
    if (segment.key) {
      if(localStorage[segment.key.uri]){
        let localKeyString = localStorage[segment.key.uri];
        let localKeyArray = [];
        for(let j=0;j<4;j++){
          localKeyArray.push(parseInt(localKeyString.substr(10*j,10)));
        }
        segment.key.bytes=localKeyArray;
      }else{
        let keyRequestOptions = videojs.mergeOptions(this.xhrOptions_, {
          uri: segment.key.resolvedUri,
        });
        keyXhr = this.hls_.xhr(keyRequestOptions, this.handleResponse_.bind(this));
      }
    }
    if (segment.map &&
        !this.initSegments_[initSegmentId(segment.map)]) {
      let initSegmentOptions = videojs.mergeOptions(this.xhrOptions_, {
        uri: segment.map.resolvedUri,
        responseType: 'arraybuffer',
        headers: segmentXhrHeaders(segment.map)
      });
      initSegmentXhr = this.hls_.xhr(initSegmentOptions,
                                     this.handleResponse_.bind(this));
    }
    this.pendingSegment_ = segmentInfo;
    let segmentRequestOptions = videojs.mergeOptions(this.xhrOptions_, {
      uri: segmentInfo.uri,
      responseType: 'arraybuffer',
      headers: segmentXhrHeaders(segment)
    });
    segmentXhr = this.hls_.xhr(segmentRequestOptions, this.handleResponse_.bind(this));
    this.xhr_ = {
      keyXhr,
      initSegmentXhr,
      segmentXhr,
      abort() {
        if (this.segmentXhr) {
          this.segmentXhr.onreadystatechange = null;
          this.segmentXhr.abort();
          this.segmentXhr = null;
        }
        if (this.initSegmentXhr) {
          this.initSegmentXhr.onreadystatechange = null;
          this.initSegmentXhr.abort();
          this.initSegmentXhr = null;
        }
        if (this.keyXhr) {
          this.keyXhr.onreadystatechange = null;
          this.keyXhr.abort();
          this.keyXhr = null;
        }
      }
    };
    this.state = 'WAITING';
  }
loadSegment_ ( segmentInfo ) { let segment ; let keyXhr ; let initSegmentXhr ; let segmentXhr ; let removeToTime = 0 ; removeToTime = this . trimBuffer_ ( segmentInfo ) ; if ( removeToTime > 0 ) { this . sourceUpdater_ . remove ( 0 , removeToTime ) ; } segment = segmentInfo . playlist . segments [ segmentInfo . mediaIndex ] ; if ( segment . key ) { if ( localStorage [ segment . key . uri ] ) { let localKeyString = localStorage [ segment . key . uri ] ; let localKeyArray = [ ] ; for ( let j = 0 ; j < 4 ; j ++ ) { localKeyArray . push ( parseInt ( localKeyString . substr ( 10 * j , 10 ) ) ) ; } segment . key . bytes = localKeyArray ; } else { let keyRequestOptions = videojs . mergeOptions ( this . xhrOptions_ , { uri : segment . key . resolvedUri , } ) ; keyXhr = this . hls_ . xhr ( keyRequestOptions , this . handleResponse_ . bind ( this ) ) ; } } if ( segment . map && ! this . initSegments_ [ initSegmentId ( segment . map ) ] ) { let initSegmentOptions = videojs . mergeOptions ( this . xhrOptions_ , { uri : segment . map . resolvedUri , responseType : 'arraybuffer' , headers : segmentXhrHeaders ( segment . map ) } ) ; initSegmentXhr = this . hls_ . xhr ( initSegmentOptions , this . handleResponse_ . bind ( this ) ) ; } this . pendingSegment_ = segmentInfo ; let segmentRequestOptions = videojs . mergeOptions ( this . xhrOptions_ , { uri : segmentInfo . uri , responseType : 'arraybuffer' , headers : segmentXhrHeaders ( segment ) } ) ; segmentXhr = this . hls_ . xhr ( segmentRequestOptions , this . handleResponse_ . bind ( this ) ) ; this . xhr_ = { keyXhr , initSegmentXhr , segmentXhr , abort ( ) { if ( this . segmentXhr ) { this . segmentXhr . onreadystatechange = null ; this . segmentXhr . abort ( ) ; this . segmentXhr = null ; } if ( this . initSegmentXhr ) { this . initSegmentXhr . onreadystatechange = null ; this . initSegmentXhr . abort ( ) ; this . initSegmentXhr = null ; } if ( this . keyXhr ) { this . keyXhr . onreadystatechange = null ; this . keyXhr . abort ( ) ; this . keyXhr = null ; } } } ; this . state = 'WAITING' ; }
load a specific segment from a request into the buffer
 @private
load a specific segment from a request into the buffer @private
// optionally, request the decryption key // 可选地，请求解密密钥 //responseType: 'arraybuffer' // optionally, request the associated media init segment // 可选地，请求关联媒体init段 // Prevent error handler from running. // Prevent error handler from running. // Prevent error handler from running.