Line data Source code
1 : import 'dart:convert';
2 :
3 : import 'package:flutter_chrome_cast/lib.dart';
4 :
5 : /// Android-specific implementation of media status.
6 : class GoogleCastAndroidMediaStatus extends GoggleCastMediaStatus {
7 : /// Creates an Android media status instance.
8 1 : GoogleCastAndroidMediaStatus({
9 : required super.mediaSessionID,
10 : required super.playerState,
11 : required super.playbackRate,
12 : required super.volume,
13 : required super.isMuted,
14 : required super.repeatMode,
15 : super.activeTrackIds,
16 : super.adBreakStatus,
17 : super.currentItemId,
18 : super.idleReason,
19 : super.liveSeekableRange,
20 : super.mediaInformation,
21 : });
22 :
23 : /// Creates a media status instance from a map.
24 1 : factory GoogleCastAndroidMediaStatus.fromMap(Map<String, dynamic> map) {
25 1 : return GoogleCastAndroidMediaStatus(
26 2 : mediaSessionID: map['mediaSessionId']?.toInt() ?? 0,
27 2 : playerState: CastMediaPlayerStateAndroid.fromMap(map['playerState']),
28 1 : idleReason: map['idleReason'] != null
29 0 : ? GoogleCastIdleReasonAndroid.fromMap(map['idleReason'])
30 : : null,
31 1 : playbackRate: map['playbackRate'] ?? 1,
32 1 : mediaInformation: map['media'] != null
33 0 : ? GoogleCastMediaInformationAndroid.fromMap(
34 0 : Map<String, dynamic>.from(map['media']))
35 : : null,
36 :
37 2 : volume: map['volume']?['level'] ?? 0,
38 2 : isMuted: map['volume']?['muted'] ?? true,
39 2 : repeatMode: GoogleCastRepeatModeAndroid.fromMap(map['repeatMode']),
40 2 : currentItemId: map['currentItemId']?.toInt(),
41 : activeTrackIds:
42 3 : List<int>.from(jsonDecode(map['activeTrackIds'] ?? '[]') ?? []),
43 :
44 : // adBreakStatus: map['adBreakStatus'] != null
45 : // ? GoogleCastBrakeStatus.fromMap(map['adBreakStatus'])
46 : // : null,
47 : // liveSeekableRange: map['liveSeekableRange'] != null
48 : // ? GoogleCastMediaLiveSeekableRange.fromMap(map['liveSeekableRange'])
49 : // : null,
50 : // queueData: map['queueData'] != null
51 : // ? GoogleCastMediaQueueData.fromMap(map['queueData'])
52 : // : null,
53 : );
54 : }
55 : }
|