feat: iOS端APP到锁声音的调优
This commit is contained in:
parent
ca48b7e9c3
commit
cc2950410b
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 错误监听
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user