|
@@ -78,8 +78,10 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
|
|
|
// 刷新设备列表
|
|
|
- void refreshDevices() {
|
|
|
- ///TODO 刷新设备列表
|
|
|
+ Future<void> refreshAllDevices() async {
|
|
|
+ await refreshCameraList();
|
|
|
+ await refreshMicrophoneList();
|
|
|
+ await refreshSpeakerList();
|
|
|
}
|
|
|
|
|
|
/// 设置当前选中的摄像头可用性
|
|
@@ -139,6 +141,14 @@ class HardwareDetectionController extends GetxController {
|
|
|
_stopPlaySound();
|
|
|
}
|
|
|
|
|
|
+ /// 开始检测所有设备
|
|
|
+ Future<void> startDetectingAll() async {
|
|
|
+ await refreshAllDevices();
|
|
|
+ if (state.cameraList.isNotEmpty) startDetectingCamera();
|
|
|
+ if (state.microphoneList.isNotEmpty) startDetectingMicrophone();
|
|
|
+ if (state.speakerList.isNotEmpty) startDetectingSpeaker();
|
|
|
+ }
|
|
|
+
|
|
|
/// 选择摄像头
|
|
|
void selectCameraById(String deviceId) {
|
|
|
if (state.currentCamera != null && deviceId == state.currentCamera!.id)
|
|
@@ -151,16 +161,14 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
});
|
|
|
if (state.currentCamera == null) return;
|
|
|
-
|
|
|
- /// 如果当前正在检测摄像头,则刷新
|
|
|
if (state.detectingCamera) {
|
|
|
_stopCamera();
|
|
|
_openSelectedCamera();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// 选择麦克风 [web 无法修改麦克风]
|
|
|
- void selectMicrophoneById(String deviceId) {
|
|
|
+ /// 选择麦克风
|
|
|
+ Future<void> selectMicrophoneById(String deviceId) async {
|
|
|
state.microphoneList.forEach((element) {
|
|
|
if (element.id == deviceId) {
|
|
|
state.currentMicrophone = element;
|
|
@@ -169,6 +177,13 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
});
|
|
|
if (state.currentMicrophone == null) return;
|
|
|
+ // TRTCCloud trtcCloud = (await TRTCCloud.sharedInstance())!;
|
|
|
+ // TXDeviceManager deviceManager = trtcCloud.getDeviceManager();
|
|
|
+ // deviceManager.setCurrentDevice(0, state.currentMicrophone!.id);
|
|
|
+ // if (state.detectingMicrophone) {
|
|
|
+ // _stopRecordMicrophone();
|
|
|
+ // _startRecordMicrophone();
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/// 选择扬声器
|
|
@@ -197,7 +212,6 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
}
|
|
|
state.deviceList.addAll(state.speakerList);
|
|
|
- print("当前总设备数量: ${state.deviceList.length}");
|
|
|
}
|
|
|
|
|
|
/// 刷新摄像头列表
|
|
@@ -214,7 +228,6 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
}
|
|
|
state.deviceList.addAll(state.cameraList);
|
|
|
- print("当前总设备数量: ${state.deviceList.length}");
|
|
|
}
|
|
|
|
|
|
/// 刷新麦克风列表
|
|
@@ -231,7 +244,6 @@ class HardwareDetectionController extends GetxController {
|
|
|
}
|
|
|
}
|
|
|
state.deviceList.addAll(state.microphoneList);
|
|
|
- print("当前总设备数量: ${state.deviceList.length}");
|
|
|
}
|
|
|
|
|
|
/// 调用 TRTC 获取摄像头列表
|