Line data Source code
1 : import 'package:flutter_chrome_cast/lib.dart';
2 :
3 : /// Represents a Google Cast session on Android devices.
4 : ///
5 : /// This class extends [GoogleCastSession] and provides Android-specific
6 : /// session details and mapping utilities.
7 : class GoogleCastSessionAndroid extends GoogleCastSession {
8 : /// Creates a [GoogleCastSessionAndroid] instance with the given parameters.
9 : ///
10 : /// [device] is the Android device associated with the session.
11 : /// [sessionID] is the unique identifier for the session.
12 : /// [connectionState] indicates the current connection state.
13 : /// [currentDeviceMuted] is true if the device is muted.
14 : /// [currentDeviceVolume] is the current volume level.
15 : /// [deviceStatusText] is a status message from the device.
16 0 : GoogleCastSessionAndroid({
17 : required super.device,
18 : required super.sessionID,
19 : required super.connectionState,
20 : required super.currentDeviceMuted,
21 : required super.currentDeviceVolume,
22 : required super.deviceStatusText,
23 : });
24 :
25 : /// Creates a [GoogleCastSessionAndroid] from a map, typically received from platform channels.
26 : ///
27 : /// The [map] parameter should contain keys for device, sessionID, connectionState, isMute, volume, and statusMessage.
28 0 : factory GoogleCastSessionAndroid.fromMap(Map<String, dynamic> map) {
29 0 : final device = map['device'];
30 0 : return GoogleCastSessionAndroid(
31 : device: device != null
32 0 : ? GoogleCastAndroidDevice.fromMap(Map.from(map['device']))
33 : : null,
34 0 : sessionID: map['sessionID'],
35 0 : connectionState: GoogleCastConnectState.values[map['connectionState']],
36 0 : currentDeviceMuted: map['isMute'],
37 0 : currentDeviceVolume: map['volume'],
38 0 : deviceStatusText: map['statusMessage'] ?? '',
39 : );
40 : }
41 : }
|