|
@@ -52,7 +52,8 @@ class HardwareSetting with TrtcClientGetterMixin {
|
|
|
|
|
|
Future<String> _getTrtcCameraNameAsync(String deviceName) async {
|
|
|
final TXDeviceManager deviceManager = client.getDeviceManager();
|
|
|
- final List<dynamic>? cameras = await deviceManager.getDevicesList(2);
|
|
|
+ final Map<dynamic, dynamic>? cameras =
|
|
|
+ await deviceManager.getDevicesList(2);
|
|
|
if (Storage.platform != Platform.Windows) {
|
|
|
switch (deviceName.toLowerCase()) {
|
|
|
case "back camera":
|
|
@@ -64,32 +65,53 @@ class HardwareSetting with TrtcClientGetterMixin {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ String cameraLabel = '';
|
|
|
if (cameras != null && cameras.isNotEmpty) {
|
|
|
- for (var camera in cameras) {
|
|
|
- if (camera['label']
|
|
|
- .toString()
|
|
|
- .toLowerCase()
|
|
|
- .contains(deviceName.toLowerCase())) {
|
|
|
- return camera['label'];
|
|
|
+ cameras.forEach((key, value) {
|
|
|
+ if (key == 'deviceList') {
|
|
|
+
|
|
|
+ if (value is List) {
|
|
|
+ for (var element in value) {
|
|
|
+ if (element is Map) {
|
|
|
+ if (element["label"]
|
|
|
+ .toString()
|
|
|
+ .toLowerCase()
|
|
|
+ .contains(deviceName.toLowerCase())) {
|
|
|
+ cameraLabel = element["label"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- return '';
|
|
|
+ return cameraLabel;
|
|
|
}
|
|
|
|
|
|
Future<String> _getTrtcMicNameAsync(String deviceName) async {
|
|
|
- final List<dynamic>? microphones = await deviceManager.getDevicesList(0);
|
|
|
+ final Map<dynamic, dynamic>? microphones =
|
|
|
+ await deviceManager.getDevicesList(0);
|
|
|
+ String micLabel = '';
|
|
|
if (microphones != null && microphones.isNotEmpty) {
|
|
|
- for (var microphone in microphones) {
|
|
|
- if (microphone['label']
|
|
|
- .toString()
|
|
|
- .toLowerCase()
|
|
|
- .contains(deviceName.toLowerCase())) {
|
|
|
- return microphone['label'];
|
|
|
+ microphones.forEach((key, value) {
|
|
|
+ if (key == 'deviceList') {
|
|
|
+
|
|
|
+ if (value is List) {
|
|
|
+ for (var element in value) {
|
|
|
+ if (element is Map) {
|
|
|
+ if (element["label"]
|
|
|
+ .toString()
|
|
|
+ .toLowerCase()
|
|
|
+ .contains(deviceName.toLowerCase())) {
|
|
|
+ micLabel = element["label"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
- return '';
|
|
|
+ return micLabel;
|
|
|
}
|
|
|
}
|