fillBuffer_() {
    if (this.sourceUpdater_.updating()) {
      return;
    }

    // see if we need to begin loading immediately
    let segmentInfo = this.checkBuffer_(this.sourceUpdater_.buffered(),
                                        this.playlist_,
                                        this.currentTime_());

    if (!segmentInfo) {
      return;
    }

    if (segmentInfo.mediaIndex === this.playlist_.segments.length - 1 &&
        this.mediaSource_.readyState === 'ended' &&
        !this.seeking_()) {
      return;
    }

    let segment = this.playlist_.segments[segmentInfo.mediaIndex];
    let startOfSegment = duration(this.playlist_,
                                  this.playlist_.mediaSequence + segmentInfo.mediaIndex,
                                  this.expired_);

    // We will need to change timestampOffset of the sourceBuffer if either of
    // the following conditions are true:
    // - The segment.timeline !== this.currentTimeline
    //   (we are crossing a discontinuity)
    // - The "timestampOffset" for the start of this segment is less than
    //   the currently set timestampOffset
    segmentInfo.timestampOffset = this.sourceUpdater_.timestampOffset();
    if (segment.timeline !== this.currentTimeline_ ||
        startOfSegment < this.sourceUpdater_.timestampOffset()) {
      segmentInfo.timestampOffset = startOfSegment;
    }

    // Sanity check the segment-index determining logic by calcuating the
    // percentage of the chosen segment that is buffered. If more than 90%
    // of the segment is buffered then fetching it will likely not help in
    // any way
    let percentBuffered = Ranges.getSegmentBufferedPercent(startOfSegment,
                                                          segment.duration,
                                                          this.currentTime_(),
                                                          this.sourceUpdater_.buffered());

    if (percentBuffered >= 90) {
      // Increment the timeCorrection_ variable to push the fetcher forward
      // in time and hopefully skip any gaps or flaws in our understanding
      // of the media
      let correctionApplied =
        this.incrementTimeCorrection_(this.playlist_.targetDuration / 2, 1);

      if (correctionApplied && !this.paused()) {
        this.fillBuffer_();
      }

      return;
    }

    this.loadSegment_(segmentInfo);
  }
/**
   * fill the buffer with segements unless the
   * sourceBuffers are currently updating
   *
   * @private
   */
fill the buffer with segements unless the
sourceBuffers are currently updating

@private
fill the buffer with segements unless the sourceBuffers are currently updating @private
fillBuffer_() {
    if (this.sourceUpdater_.updating()) {
      return;
    }
    let segmentInfo = this.checkBuffer_(this.sourceUpdater_.buffered(),
                                        this.playlist_,
                                        this.currentTime_());
    if (!segmentInfo) {
      return;
    }
    if (segmentInfo.mediaIndex === this.playlist_.segments.length - 1 &&
        this.mediaSource_.readyState === 'ended' &&
        !this.seeking_()) {
      return;
    }
    let segment = this.playlist_.segments[segmentInfo.mediaIndex];
    let startOfSegment = duration(this.playlist_,
                                  this.playlist_.mediaSequence + segmentInfo.mediaIndex,
                                  this.expired_);
    segmentInfo.timestampOffset = this.sourceUpdater_.timestampOffset();
    if (segment.timeline !== this.currentTimeline_ ||
        startOfSegment < this.sourceUpdater_.timestampOffset()) {
      segmentInfo.timestampOffset = startOfSegment;
    }
    let percentBuffered = Ranges.getSegmentBufferedPercent(startOfSegment,
                                                          segment.duration,
                                                          this.currentTime_(),
                                                          this.sourceUpdater_.buffered());
    if (percentBuffered >= 90) {
      let correctionApplied =
        this.incrementTimeCorrection_(this.playlist_.targetDuration / 2, 1);
      if (correctionApplied && !this.paused()) {
        this.fillBuffer_();
      }
      return;
    }
    this.loadSegment_(segmentInfo);
  }
fillBuffer_ ( ) { if ( this . sourceUpdater_ . updating ( ) ) { return ; } let segmentInfo = this . checkBuffer_ ( this . sourceUpdater_ . buffered ( ) , this . playlist_ , this . currentTime_ ( ) ) ; if ( ! segmentInfo ) { return ; } if ( segmentInfo . mediaIndex === this . playlist_ . segments . length - 1 && this . mediaSource_ . readyState === 'ended' && ! this . seeking_ ( ) ) { return ; } let segment = this . playlist_ . segments [ segmentInfo . mediaIndex ] ; let startOfSegment = duration ( this . playlist_ , this . playlist_ . mediaSequence + segmentInfo . mediaIndex , this . expired_ ) ; segmentInfo . timestampOffset = this . sourceUpdater_ . timestampOffset ( ) ; if ( segment . timeline !== this . currentTimeline_ || startOfSegment < this . sourceUpdater_ . timestampOffset ( ) ) { segmentInfo . timestampOffset = startOfSegment ; } let percentBuffered = Ranges . getSegmentBufferedPercent ( startOfSegment , segment . duration , this . currentTime_ ( ) , this . sourceUpdater_ . buffered ( ) ) ; if ( percentBuffered >= 90 ) { let correctionApplied = this . incrementTimeCorrection_ ( this . playlist_ . targetDuration / 2 , 1 ) ; if ( correctionApplied && ! this . paused ( ) ) { this . fillBuffer_ ( ) ; } return ; } this . loadSegment_ ( segmentInfo ) ; }
fill the buffer with segements unless the
 sourceBuffers are currently updating
fill the buffer with segements unless the sourceBuffers are currently updating
// see if we need to begin loading immediately // We will need to change timestampOffset of the sourceBuffer if either of // the following conditions are true: // - The segment.timeline !== this.currentTimeline //   (we are crossing a discontinuity) // - The "timestampOffset" for the start of this segment is less than //   the currently set timestampOffset // Sanity check the segment-index determining logic by calcuating the // percentage of the chosen segment that is buffered. If more than 90% // of the segment is buffered then fetching it will likely not help in // any way // Increment the timeCorrection_ variable to push the fetcher forward // in time and hopefully skip any gaps or flaws in our understanding // of the media