parse static method

Future<PipFlutterPlayerAsmsDataHolder> parse(
  1. String data,
  2. String masterPlaylistUrl
)

Implementation

static Future<PipFlutterPlayerAsmsDataHolder> parse(
    String data, String masterPlaylistUrl) async {
  List<PipFlutterPlayerAsmsTrack> tracks = [];
  final List<PipFlutterPlayerAsmsAudioTrack> audios = [];
  final List<PipFlutterPlayerAsmsSubtitle> subtitles = [];
  try {
    int audiosCount = 0;
    final document = XmlDocument.parse(data);
    final adaptationSets = document.findAllElements('AdaptationSet');
    adaptationSets.forEach((node) {
      final mimeType = node.getAttribute('mimeType');

      if (mimeType != null) {
        if (MimeTypes.isVideo(mimeType)) {
          tracks = tracks + parseVideo(node);
        } else if (MimeTypes.isAudio(mimeType)) {
          audios.add(parseAudio(node, audiosCount));
          audiosCount += 1;
        } else if (MimeTypes.isText(mimeType)) {
          subtitles.add(parseSubtitle(masterPlaylistUrl, node));
        }
      }
    });
  } catch (exception) {
    PipFlutterPlayerUtils.log("Exception on dash parse: $exception");
  }
  return PipFlutterPlayerAsmsDataHolder(
      tracks: tracks, audios: audios, subtitles: subtitles);
}