Line data Source code
1 : import 'dart:convert';
2 :
3 : /// Represents current status of a break, including IDs and timing information.
4 : class GoogleCastBrakeStatus {
5 : /// ID of the current break clip.
6 : final String? breakClipId;
7 :
8 : /// ID of the current break.
9 : final String? breakId;
10 :
11 : /// Time in seconds elapsed after the current break clip starts.
12 : /// This member is only updated sporadically, so its value is often out of date.
13 : /// Use the getEstimatedBreakClipTime method to get an estimate of the real playback position.
14 : final Duration? currentBreakClipTime;
15 :
16 : /// Time in seconds elapsed after the current break starts.
17 : /// This member is only updated sporadically, so its value is often out of date.
18 : /// Use the getEstimatedBreakTime method to get an estimate of the real playback position.
19 : final Duration? currentBreakTime;
20 :
21 : /// The time in seconds when this break clip becomes skippable.
22 : /// If not defined, the current break clip is not skippable.
23 : final Duration? whenSkippable;
24 :
25 : /// Creates a new [GoogleCastBrakeStatus] instance.
26 0 : GoogleCastBrakeStatus({
27 : this.breakClipId,
28 : this.breakId,
29 : this.currentBreakClipTime,
30 : this.currentBreakTime,
31 : this.whenSkippable,
32 : });
33 :
34 : /// Converts the object to a map for serialization.
35 0 : Map<String, dynamic> toMap() {
36 0 : return {
37 0 : 'breakClipId': breakClipId,
38 0 : 'breakId': breakId,
39 0 : 'currentBreakClipTime': currentBreakClipTime?.inSeconds,
40 0 : 'currentBreakTime': currentBreakTime?.inSeconds,
41 0 : 'whenSkippable': whenSkippable?.inSeconds,
42 : };
43 : }
44 :
45 : /// Creates a [GoogleCastBrakeStatus] from a map.
46 0 : factory GoogleCastBrakeStatus.fromMap(Map<String, dynamic> map) {
47 0 : return GoogleCastBrakeStatus(
48 0 : breakClipId: map['breakClipId'],
49 0 : breakId: map['breakId'],
50 0 : currentBreakClipTime: map['currentBreakClipTime'] != null
51 0 : ? Duration(seconds: map['currentBreakClipTime'].toInt())
52 : : null,
53 0 : currentBreakTime: map['currentBreakTime'] != null
54 0 : ? Duration(seconds: map['currentBreakTime'].toInt())
55 : : null,
56 0 : whenSkippable: map['whenSkippable'] != null
57 0 : ? Duration(seconds: map['whenSkippable'].toInt())
58 : : null,
59 : );
60 : }
61 :
62 : /// Converts the object to a JSON string.
63 0 : String toJson() => json.encode(toMap());
64 :
65 : /// Creates a [GoogleCastBrakeStatus] from a JSON string.
66 0 : factory GoogleCastBrakeStatus.fromJson(String source) =>
67 0 : GoogleCastBrakeStatus.fromMap(json.decode(source));
68 : }
|