From e0e4c32e7a410bc3bf17c38290fcd4fd46356df6 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 16 Apr 2024 09:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9=E8=AE=B2=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=92=AD=E6=94=BE=E9=9F=B3=E9=A2=91=E6=96=B9=E6=B3=95?= =?UTF-8?q?=20=E5=BD=95=E9=9F=B3=E6=8F=92=E4=BB=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitoring/lockMonitoring_logic.dart | 20 ++++++++++--------- star_lock/lib/talk/call/callTalk.dart | 18 ++--------------- star_lock/pubspec.yaml | 2 +- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart index a9289aea..236919b4 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart @@ -148,9 +148,9 @@ class LockMonitoringLogic extends BaseGetXController { //开始录音 Future startProcessing() async { - if (state.isProcessing.value) { - CallTalk().stopPlaySound(); - } + // if (state.isProcessing.value) { + // CallTalk().stopPlaySound(); + // } state.isButtonDisabled.value = true; state.voiceProcessor?.addFrameListener(_onFrame); @@ -171,9 +171,9 @@ class LockMonitoringLogic extends BaseGetXController { } Future _onFrame(List frame) async { - if (state.isProcessing.value) { - CallTalk().stopPlaySound(); - } + // if (state.isProcessing.value) { + // CallTalk().stopPlaySound(); + // } state.allFrames.add(frame); // 将帧添加到状态变量中 List concatenatedFrames = concatenateFrames(state.allFrames); // 连接所有帧 Get.log("pcm数据:$concatenatedFrames"); @@ -204,9 +204,11 @@ class LockMonitoringLogic extends BaseGetXController { } Future stopProcessing() async { - if (state.isProcessing.value) { - CallTalk().stopPlaySound(); - } + // if (state.isProcessing.value) { + // CallTalk().stopPlaySound(); + // } else { + // CallTalk().startPlaySound(); + // } state.isButtonDisabled.value = true; try { await state.voiceProcessor?.stop(); diff --git a/star_lock/lib/talk/call/callTalk.dart b/star_lock/lib/talk/call/callTalk.dart index b313d2c8..342f506c 100644 --- a/star_lock/lib/talk/call/callTalk.dart +++ b/star_lock/lib/talk/call/callTalk.dart @@ -123,26 +123,12 @@ class CallTalk { // Get.log('_initializeAudioPlayer audioData:$audioData'); PcmArrayInt16 fromList = PcmArrayInt16.fromList(audioData); - // FlutterPcmSound.setFeedCallback(onFeed); await FlutterPcmSound.feed(fromList); FlutterPcmSound.play(); } - void onFeed(int remainingFrames) async { - int framesToFeed = 320; - - if (allDataBytes.length >= framesToFeed) { - List frames = allDataBytes.sublist(0, framesToFeed); - allDataBytes.removeRange(0, framesToFeed); - - // 将数据传递给 FlutterPcmSound - PcmArrayInt16 fromList = PcmArrayInt16.fromList(frames); - await FlutterPcmSound.feed(fromList); - FlutterPcmSound.play(); - } else { - // 处理长度不足的情况,可以等待更多数据或者采取其他措施 - print("Not enough data in allPcmData."); - } + void startPlaySound() { + FlutterPcmSound.play(); } void stopPlaySound() { diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 6ee6748b..c6c9e80f 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -148,7 +148,7 @@ dependencies: intl: ^0.18.0 # flutter_audio_capture: <1.1.5 - flutter_voice_processor: ^1.1.0 + flutter_voice_processor: ^1.1.1 #监听网络连接状态 connectivity_plus: ^5.0.2 #flutter_advanced_calendar: ^1.4.1