parseHlsMasterPlaylist static method

Future<HlsMasterPlaylist?> parseHlsMasterPlaylist(
  1. String url, {
  2. Map<String, Object>? headers,
})

Parses the HLS master playlist from the given url.

url: The URL of the HLS master playlist. headers: Optional HTTP headers for the request.

Returns an HlsMasterPlaylist instance if successful, otherwise returns null.

Implementation

static Future<HlsMasterPlaylist?> parseHlsMasterPlaylist(
  String url, {
  Map<String, Object>? headers,
}) async {
  Uri uri = url.toSafeUri();
  UrlParser parser = UrlParserFactory.createParser(uri);
  if (parser is! UrlParserM3U8) return null;
  HlsPlaylist? playlist = await parser.parsePlaylist(uri,
      headers: headers, hlsKey: uri.generateMd5);
  return playlist is HlsMasterPlaylist ? playlist : null;
}