fromMap static method

TrackInfo fromMap(
  1. Map map
)

Implementation

static TrackInfo fromMap(Map map) {
  final type = map['type'] as String;
  final format = map['format'] as String?;
  final language = map['language'] as String?;
  final title = map['title'] as String?;
  final bitRate = map['bitRate'] as int?;
  final videoSize = map['width'] == null ||
          map['height'] == null ||
          map['width'] <= 0 ||
          map['height'] <= 0
      ? null
      : Size(map['width'].toDouble(), map['height'].toDouble());
  final frameRate = map['frameRate'] as double?;
  final channels = map['channels'] as int?;
  final sampleRate = map['sampleRate'] as int?;
  final isHdr = map['isHdr'] as bool?;
  return TrackInfo(
    type == 'audio'
        ? TrackType.audio
        : type == 'video'
            ? TrackType.video
            : TrackType.subtitle,
    format: format == "" ? null : format,
    language: language == "" ? null : language,
    title: title == "" ? null : title,
    isHdr: isHdr,
    videoSize: videoSize,
    frameRate: frameRate != null && frameRate > 0 ? frameRate : null,
    bitRate: bitRate != null && bitRate > 0 ? bitRate : null,
    channels: channels != null && channels > 0 ? channels : null,
    sampleRate: sampleRate != null && sampleRate > 0 ? sampleRate : null,
  );
}