parse method
Implementation
Future<HlsPlaylist> parse(Uri? uri, List<String> inputLineList) async {
final List<String> lineList = inputLineList
.where((line) => line.trim().isNotEmpty) // ignore: always_specify_types
.toList();
if (!_checkPlaylistHeader(lineList[0])) {
throw UnrecognizedInputFormatException(
'Input does not start with the #EXTM3U header.', uri);
}
final List<String> extraLines =
lineList.getRange(1, lineList.length).toList();
bool? isMasterPlayList;
for (final line in extraLines) {
if (line.startsWith(tagStreamInf)) {
isMasterPlayList = true;
break;
} else if (line.startsWith(tagTargetDuration) ||
line.startsWith(tagMediaSequence) ||
line.startsWith(tagMediaDuration) ||
line.startsWith(tagKey) ||
line.startsWith(tagByteRange) ||
line == tagDiscontinuity ||
line == tagDiscontinuitySequence ||
line == tagEndList) {
isMasterPlayList = false;
}
}
if (isMasterPlayList == null) {
throw const FormatException("extraLines doesn't have valid tag");
}
return isMasterPlayList
? _parseMasterPlaylist(extraLines.iterator, uri.toString())
: _parseMediaPlaylist(masterPlaylist, extraLines, uri.toString());
}