parsePlaylist method
Parses the HLS playlist (master or media) from the given uri
.
Returns an HlsPlaylist if successful, otherwise null
.
Implementation
Future<HlsPlaylist?> parsePlaylist(
Uri uri, {
Map<String, Object>? headers,
String? hlsKey,
}) async {
DownloadTask task = DownloadTask(
uri: uri,
headers: headers,
hlsKey: hlsKey ?? uri.generateMd5,
);
Uint8List? uint8List = await cache(task);
if (uint8List == null) uint8List = await download(task);
if (uint8List == null) return null;
List<String> lines = readLineFromUint8List(uint8List);
final HlsPlaylist? playList = await parseLines(lines);
return playList;
}