GoogleCastMediaTrack.fromMap constructor

GoogleCastMediaTrack.fromMap(
  1. Map<String, dynamic> map
)

Creates a GoogleCastMediaTrack from a map.

Implementation

factory GoogleCastMediaTrack.fromMap(Map<String, dynamic> map) {
  return GoogleCastMediaTrack(
    customData: Map<String, dynamic>.from(map['customData'] ?? {}),
    language: map['language'] != null
        ? Rfc5646Language.fromMap(map['language'])
        : null,
    name: map['name'],
    subtype: map['subtype'] != null
        ? TextTrackType.values.firstWhere(
            (e) => e.name == map['subtype'],
            orElse: () => TextTrackType.unknown,
          )
        : null,
    trackContentId: map['trackContentId'],
    // In-band receiver tracks are allowed to omit a content type. Android's
    // MediaTrack.toMap() consequently sends null for those tracks, so keep
    // the public non-nullable API stable while parsing the missing value
    // safely. Outbound tracks created by callers still provide a MIME type.
    trackContentType: map['trackContentType'] as String? ?? '',
    trackId: map['trackId']?.toInt() ?? 0,
    type: GoogleCastTrackTypeAndroid.fromMap(map['type']),
  );
}