HlsMediaPlaylist.create constructor

HlsMediaPlaylist.create({
  1. required int playlistType,
  2. required int? startOffsetUs,
  3. required int? startTimeUs,
  4. required bool hasDiscontinuitySequence,
  5. required int discontinuitySequence,
  6. required int? mediaSequence,
  7. required int? version,
  8. required int? targetDurationUs,
  9. required bool hasEndTag,
  10. required bool hasProgramDateTime,
  11. required DrmInitData? protectionSchemes,
  12. required List<Segment> segments,
  13. required String baseUri,
  14. required List<String> tags,
  15. required bool hasIndependentSegments,
})

Implementation

factory HlsMediaPlaylist.create({
  required int playlistType,
  required int? startOffsetUs,
  required int? startTimeUs,
  required bool hasDiscontinuitySequence,
  required int discontinuitySequence,
  required int? mediaSequence,
  required int? version,
  required int? targetDurationUs,
  required bool hasEndTag,
  required bool hasProgramDateTime,
  required DrmInitData? protectionSchemes,
  required List<Segment> segments,
  required String baseUri,
  required List<String> tags,
  required bool hasIndependentSegments,
}) {
  final int? durationUs = segments.isNotEmpty
      ? segments.last.relativeStartTimeUs ?? 0 + segments.last.durationUs!
      : null;

  if (startOffsetUs != null && startOffsetUs < 0) {
    startOffsetUs = durationUs ?? 0 + startOffsetUs;
  }

  return HlsMediaPlaylist._(
    playlistType: playlistType,
    startOffsetUs: startOffsetUs,
    startTimeUs: startTimeUs,
    hasDiscontinuitySequence: hasDiscontinuitySequence,
    discontinuitySequence: discontinuitySequence,
    mediaSequence: mediaSequence,
    version: version,
    targetDurationUs: targetDurationUs,
    hasEndTag: hasEndTag,
    hasProgramDateTime: hasProgramDateTime,
    protectionSchemes: protectionSchemes,
    segments: segments,
    durationUs: durationUs,
    baseUri: baseUri,
    tags: tags,
    hasIndependentSegments: hasIndependentSegments,
  );
}