feat: iOS端APP到锁声音的调优

This commit is contained in:
“DaisyWu” 2025-02-24 19:01:38 +08:00
parent ca48b7e9c3
commit cc2950410b

View File

@ -47,7 +47,7 @@ class TalkViewLogic extends BaseGetXController {
int minFrameIntervalMs = 30; // 33 FPS
int maxFrameIntervalMs = 100; // 1 FPS
//
List<int> _bufferedAudioFrames = <int>[];
final List<int> _bufferedAudioFrames = <int>[];
///
void _initFlutterPcmSound() {
@ -565,8 +565,8 @@ class TalkViewLogic extends BaseGetXController {
state.endRecordingAudioTime.value = DateTime.now();
//
final duration = state.endRecordingAudioTime.value!
.difference(state.startRecordingAudioTime.value!);
final Duration duration = state.endRecordingAudioTime.value
.difference(state.startRecordingAudioTime.value);
state.recordingAudioTime.value = duration.inSeconds;
} on PlatformException catch (ex) {
@ -587,16 +587,25 @@ class TalkViewLogic extends BaseGetXController {
final int ms = DateTime.now().millisecondsSinceEpoch -
state.startRecordingAudioTime.value.millisecondsSinceEpoch;
Future.delayed(const Duration(milliseconds: 1000)).whenComplete(() async {
int getFrameLength = state.frameLength;
if (Platform.isIOS) {
getFrameLength = state.frameLength * 2;
}
if (_bufferedAudioFrames.length >= getFrameLength) {
// UDP
await StartChartManage().sendTalkDataMessage(
await StartChartManage()
.sendTalkDataMessage(
talkData: TalkData(
content: list,
content: _bufferedAudioFrames,
contentType: TalkData_ContentTypeE.G711,
durationMs: ms,
),
);
});
)
.then((value) {
_bufferedAudioFrames.clear();
});
}
}
//