|
@@ -177,13 +177,10 @@ 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();
|
|
|
- // }
|
|
|
+ if (state.detectingMicrophone) {
|
|
|
+ await _stopRecordMicrophone();
|
|
|
+ _startRecordMicrophone();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 选择扬声器
|
|
@@ -297,6 +294,9 @@ class HardwareDetectionController extends GetxController {
|
|
|
return deviceList;
|
|
|
}
|
|
|
|
|
|
+ /// TODO 调用 js 获取所有设备列表
|
|
|
+ /// const devices = await navigator.mediaDevices.enumerateDevices();
|
|
|
+
|
|
|
/// 打开当前选中的摄像头
|
|
|
_openSelectedCamera() {
|
|
|
bool found = false;
|
|
@@ -365,12 +365,22 @@ class HardwareDetectionController extends GetxController {
|
|
|
|
|
|
// 开始采集麦克风音频
|
|
|
void _startRecordMicrophone() async {
|
|
|
+ /// 获取到当前选中的麦克风的id
|
|
|
+ if (state.currentMicrophone == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final String fileNameWithMicrophoneId =
|
|
|
+ "${state.currentMicrophone!.id}.webm";
|
|
|
+
|
|
|
+ /// 将麦克风的id作为文件名,web端的record会做处理,会将文件名作为选中的麦克风id进行设置
|
|
|
await flutterRecorder.startRecorder(
|
|
|
- toFile: _mPath, codec: _codec, audioSource: AudioSource.microphone);
|
|
|
+ toFile: fileNameWithMicrophoneId,
|
|
|
+ codec: _codec,
|
|
|
+ audioSource: AudioSource.microphone);
|
|
|
}
|
|
|
|
|
|
/// 停止采集麦克风音频
|
|
|
- void _stopRecordMicrophone() async {
|
|
|
+ Future<void> _stopRecordMicrophone() async {
|
|
|
await flutterRecorder.stopRecorder();
|
|
|
}
|
|
|
|