Line data Source code
1 : /// Represents different types of cast status events.
2 : ///
3 : /// These events are used to categorize different types of status updates
4 : /// that can be received from a Google Cast session.
5 : enum CastStatusType {
6 : /// Media status events related to playback state, position, etc.
7 : mediaStatus('MEDIA_STATUS'),
8 :
9 : /// Receiver status events related to device state, volume, etc.
10 : receiverStatus('RECEIVER_STATUS'),
11 :
12 : /// Unknown or unhandled status event type.
13 : unknow('UNKNOW');
14 :
15 : /// The raw string value associated with this status type.
16 : final String rawValue;
17 :
18 : /// Creates a cast status type with the given raw value.
19 : const CastStatusType(this.rawValue);
20 :
21 : /// Creates a [CastStatusType] from a string value.
22 : ///
23 : /// Returns [CastStatusType.unknow] if the string doesn't match any known type.
24 0 : factory CastStatusType.fromString(String name) {
25 0 : return CastStatusType.values.firstWhere(
26 0 : (element) => element.rawValue == name,
27 0 : orElse: () => CastStatusType.unknow);
28 : }
29 : }
30 :
31 : /// Represents a cast message event received from a Google Cast session.
32 : ///
33 : /// This class encapsulates status updates and other messages that are
34 : /// sent from the Cast receiver to the sender application.
35 : class CastMessageEvent {
36 : /// The type of status event this message represents.
37 : final CastStatusType type;
38 :
39 : /// Creates a new cast message event.
40 : ///
41 : /// [type] specifies the category of this status event.
42 0 : CastMessageEvent({
43 : required this.type,
44 : });
45 : }
|