parseTracks static method

Future<List<PipFlutterPlayerAsmsTrack>> parseTracks(
  1. String data,
  2. String masterPlaylistUrl
)

Implementation

static Future<List<PipFlutterPlayerAsmsTrack>> parseTracks(
    String data, String masterPlaylistUrl) async {
  final List<PipFlutterPlayerAsmsTrack> tracks = [];
  try {
    final parsedPlaylist = await HlsPlaylistParser.create()
        .parseString(Uri.parse(masterPlaylistUrl), data);
    if (parsedPlaylist is HlsMasterPlaylist) {
      parsedPlaylist.variants.forEach(
        (variant) {
          tracks.add(PipFlutterPlayerAsmsTrack('', variant.format.width,
              variant.format.height, variant.format.bitrate, 0, '', ''));
        },
      );
    }

    if (tracks.isNotEmpty) {
      tracks.insert(0, PipFlutterPlayerAsmsTrack.defaultTrack());
    }
  } catch (exception) {
    PipFlutterPlayerUtils.log("Exception on parseSubtitles: $exception");
  }
  return tracks;
}