library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java
/**
   * Merges the skipped segments of the previous playlist and returns a copy with a {@link
   * #skippedSegmentCount} of 0.
   *
   * @param previousPlaylist The previous playlist with a {@link #skippedSegmentCount} of zero.
   * @return A new playlist with a complete list of segments.
   */
Merges the skipped segments of the previous playlist and returns a copy with a {@link
#skippedSegmentCount} of 0.

@param previousPlaylist The previous playlist with a  #skippedSegmentCount of zero.
@return A new playlist with a complete list of segments.
Merges the skipped segments of the previous playlist and returns a copy with a { @link #skippedSegmentCount } of 0 . @param previousPlaylist The previous playlist with a #skippedSegmentCount of zero . @return A new playlist with a complete list of segments .
public HlsMediaPlaylist expandSkippedSegments(HlsMediaPlaylist previousPlaylist) {
    if (skippedSegmentCount == 0) {
      return this;
    }
    checkArgument(previousPlaylist.skippedSegmentCount == 0);
    List<Segment> mergedSegments = new ArrayList<>();
    long mediaSequence = this.mediaSequence;
    int startIndex = (int) (mediaSequence - previousPlaylist.mediaSequence);
    int endIndex = startIndex + skippedSegmentCount;
    if (startIndex >= 0 && endIndex <= previousPlaylist.segments.size()) {
      mergedSegments.addAll(previousPlaylist.segments.subList(startIndex, endIndex));
    } else {
      mediaSequence += skippedSegmentCount;
    }
    mergedSegments.addAll(segments);
    return new HlsMediaPlaylist(
        playlistType,
        baseUri,
        tags,
        startOffsetUs,
        startTimeUs,
        hasDiscontinuitySequence,
        discontinuitySequence,
        mediaSequence,
        version,
        targetDurationUs,
        partTargetDurationUs,
        hasIndependentSegments,
        hasEndTag,
        hasProgramDateTime,
        protectionSchemes,
        mergedSegments,
        /* skippedSegmentCount= */ 0,
        trailingParts,
        serverControl,
        renditionReports);
  }
public HlsMediaPlaylist expandSkippedSegments ( HlsMediaPlaylist previousPlaylist ) { if ( skippedSegmentCount == 0 ) { return this ; } checkArgument ( previousPlaylist . skippedSegmentCount == 0 ) ; List < Segment > mergedSegments = new ArrayList < > ( ) ; long mediaSequence = this . mediaSequence ; int startIndex = ( int ) ( mediaSequence - previousPlaylist . mediaSequence ) ; int endIndex = startIndex + skippedSegmentCount ; if ( startIndex >= 0 && endIndex <= previousPlaylist . segments . size ( ) ) { mergedSegments . addAll ( previousPlaylist . segments . subList ( startIndex , endIndex ) ) ; } else { mediaSequence += skippedSegmentCount ; } mergedSegments . addAll ( segments ) ; return new HlsMediaPlaylist ( playlistType , baseUri , tags , startOffsetUs , startTimeUs , hasDiscontinuitySequence , discontinuitySequence , mediaSequence , version , targetDurationUs , partTargetDurationUs , hasIndependentSegments , hasEndTag , hasProgramDateTime , protectionSchemes , mergedSegments , /* skippedSegmentCount= */ 0 , trailingParts , serverControl , renditionReports ) ; }
Merges the skipped segments of the previous playlist and returns a copy with a {@link
 #skippedSegmentCount} of 0.
Merges the skipped segments of the previous playlist and returns a copy with a { @link #skippedSegmentCount } of 0 .
// Adjust the media sequence if the old playlist doesn't contain all of the skipped segments.