checkBuffer_(buffered, playlist, currentTime) {
    let currentBuffered = Ranges.findRange(buffered, currentTime);

    // There are times when MSE reports the first segment as starting a
    // little after 0-time so add a fudge factor to try and fix those cases
    // or we end up fetching the same first segment over and over
    if (currentBuffered.length === 0 && currentTime === 0) {
      currentBuffered = Ranges.findRange(buffered,
                                         currentTime + Ranges.TIME_FUDGE_FACTOR);
    }

    let bufferedTime;
    let currentBufferedEnd;
    let segment;
    let mediaIndex;

    if (!playlist.segments.length) {
      return;
    }

    if (currentBuffered.length === 0) {
      // find the segment containing currentTime
      mediaIndex = getMediaIndexForTime(playlist,
                                        currentTime + this.timeCorrection_,
                                        this.expired_);
    } else {
      // find the segment adjacent to the end of the current
      // buffered region
      currentBufferedEnd = currentBuffered.end(0);
      bufferedTime = Math.max(0, currentBufferedEnd - currentTime);

      // if the video has not yet played only, and we already have
      // one segment downloaded do nothing
      if (!this.hasPlayed_() && bufferedTime >= 1) {
        return null;
      }

      // if there is plenty of content buffered, and the video has
      // been played before relax for awhile
      if (this.hasPlayed_() && bufferedTime >= Config.GOAL_BUFFER_LENGTH) {
        return null;
      }
      mediaIndex = getMediaIndexForTime(playlist,
                                        currentBufferedEnd + this.timeCorrection_,
                                        this.expired_);
    }

    if (mediaIndex < 0 || mediaIndex === playlist.segments.length) {
      return null;
    }

    segment = playlist.segments[mediaIndex];
    return {
      // resolve the segment URL relative to the playlist
      uri: segment.resolvedUri,
      // the segment's mediaIndex at the time it was requested
      mediaIndex,
      // the segment's playlist
      playlist,
      // unencrypted bytes of the segment
      bytes: null,
      // when a key is defined for this segment, the encrypted bytes
      encryptedBytes: null,
      // the state of the buffer before a segment is appended will be
      // stored here so that the actual segment duration can be
      // determined after it has been appended
      buffered: null,
      // The target timestampOffset for this segment when we append it
      // to the source buffer
      timestampOffset: NaN,
      // The timeline that the segment is in
      timeline: segment.timeline,
      // The expected duration of the segment in seconds
      duration: segment.duration
    };
  }
/**
   * Determines what segment request should be made, given current
   * playback state.
   *
   * @param {TimeRanges} buffered - the state of the buffer
   * @param {Object} playlist - the playlist object to fetch segments from
   * @param {Number} currentTime - the playback position in seconds
   * @returns {Object} a segment info object that describes the
   * request that should be made or null if no request is necessary
   */
Determines what segment request should be made, given current
playback state.

@param {TimeRanges} buffered - the state of the buffer
@param {Object} playlist - the playlist object to fetch segments from
@param {Number} currentTime - the playback position in seconds
@returns {Object} a segment info object that describes the
request that should be made or null if no request is necessary
Determines what segment request should be made given current playback state . @param { TimeRanges } buffered - the state of the buffer @param { Object } playlist - the playlist object to fetch segments from @param { Number } currentTime - the playback position in seconds @returns { Object } a segment info object that describes the request that should be made or null if no request is necessary
checkBuffer_(buffered, playlist, currentTime) {
    let currentBuffered = Ranges.findRange(buffered, currentTime);
    if (currentBuffered.length === 0 && currentTime === 0) {
      currentBuffered = Ranges.findRange(buffered,
                                         currentTime + Ranges.TIME_FUDGE_FACTOR);
    }
    let bufferedTime;
    let currentBufferedEnd;
    let segment;
    let mediaIndex;
    if (!playlist.segments.length) {
      return;
    }
    if (currentBuffered.length === 0) {
      mediaIndex = getMediaIndexForTime(playlist,
                                        currentTime + this.timeCorrection_,
                                        this.expired_);
    } else {
      currentBufferedEnd = currentBuffered.end(0);
      bufferedTime = Math.max(0, currentBufferedEnd - currentTime);
      if (!this.hasPlayed_() && bufferedTime >= 1) {
        return null;
      }
      if (this.hasPlayed_() && bufferedTime >= Config.GOAL_BUFFER_LENGTH) {
        return null;
      }
      mediaIndex = getMediaIndexForTime(playlist,
                                        currentBufferedEnd + this.timeCorrection_,
                                        this.expired_);
    }
    if (mediaIndex < 0 || mediaIndex === playlist.segments.length) {
      return null;
    }
    segment = playlist.segments[mediaIndex];
    return {
      uri: segment.resolvedUri,
      mediaIndex,
      playlist,
      bytes: null,
      encryptedBytes: null,
      buffered: null,
      timestampOffset: NaN,
      timeline: segment.timeline,
      duration: segment.duration
    };
  }
checkBuffer_ ( buffered , playlist , currentTime ) { let currentBuffered = Ranges . findRange ( buffered , currentTime ) ; if ( currentBuffered . length === 0 && currentTime === 0 ) { currentBuffered = Ranges . findRange ( buffered , currentTime + Ranges . TIME_FUDGE_FACTOR ) ; } let bufferedTime ; let currentBufferedEnd ; let segment ; let mediaIndex ; if ( ! playlist . segments . length ) { return ; } if ( currentBuffered . length === 0 ) { mediaIndex = getMediaIndexForTime ( playlist , currentTime + this . timeCorrection_ , this . expired_ ) ; } else { currentBufferedEnd = currentBuffered . end ( 0 ) ; bufferedTime = Math . max ( 0 , currentBufferedEnd - currentTime ) ; if ( ! this . hasPlayed_ ( ) && bufferedTime >= 1 ) { return null ; } if ( this . hasPlayed_ ( ) && bufferedTime >= Config . GOAL_BUFFER_LENGTH ) { return null ; } mediaIndex = getMediaIndexForTime ( playlist , currentBufferedEnd + this . timeCorrection_ , this . expired_ ) ; } if ( mediaIndex < 0 || mediaIndex === playlist . segments . length ) { return null ; } segment = playlist . segments [ mediaIndex ] ; return { uri : segment . resolvedUri , mediaIndex , playlist , bytes : null , encryptedBytes : null , buffered : null , timestampOffset : NaN , timeline : segment . timeline , duration : segment . duration } ; }
Determines what segment request should be made, given current
 playback state.
Determines what segment request should be made given current playback state .
// There are times when MSE reports the first segment as starting a // little after 0-time so add a fudge factor to try and fix those cases // or we end up fetching the same first segment over and over // find the segment containing currentTime // find the segment adjacent to the end of the current // buffered region // if the video has not yet played only, and we already have // one segment downloaded do nothing // if there is plenty of content buffered, and the video has // been played before relax for awhile // resolve the segment URL relative to the playlist // the segment's mediaIndex at the time it was requested // the segment's playlist // unencrypted bytes of the segment // when a key is defined for this segment, the encrypted bytes // the state of the buffer before a segment is appended will be // stored here so that the actual segment duration can be // determined after it has been appended // The target timestampOffset for this segment when we append it // to the source buffer // The timeline that the segment is in // The expected duration of the segment in seconds