Commit 48445a3bf179e42d16c29e61f38a65d3e8732eac
1 parent
e39984d8
feat:修复先声录音对音频会话的类别和模式设置影响了音频输出,导致单通道出声(听筒)
Showing
1 changed file
with
12 additions
and
1 deletions
lib/pages/reading/bloc/reading_bloc.dart
@@ -130,6 +130,9 @@ class ReadingPageBloc | @@ -130,6 +130,9 @@ class ReadingPageBloc | ||
130 | "setMethodCallHandler method=${call.method} arguments=${call.arguments}"); | 130 | "setMethodCallHandler method=${call.method} arguments=${call.arguments}"); |
131 | if (call.method == 'voiceResult') { | 131 | if (call.method == 'voiceResult') { |
132 | //评测结果 | 132 | //评测结果 |
133 | + await audioPlayer.setAudioContext(const AudioContext( | ||
134 | + iOS: AudioContextIOS() | ||
135 | + )); | ||
133 | await audioPlayer.setBalance(0.0); | 136 | await audioPlayer.setBalance(0.0); |
134 | add(XSVoiceResultEvent(call.arguments)); | 137 | add(XSVoiceResultEvent(call.arguments)); |
135 | return; | 138 | return; |
@@ -151,6 +154,9 @@ class ReadingPageBloc | @@ -151,6 +154,9 @@ class ReadingPageBloc | ||
151 | print(call.method == 'voiceEnd' ? '评测结束' : '评测取消'); | 154 | print(call.method == 'voiceEnd' ? '评测结束' : '评测取消'); |
152 | } | 155 | } |
153 | _isRecording = false; | 156 | _isRecording = false; |
157 | + await audioPlayer.setAudioContext(const AudioContext( | ||
158 | + iOS: AudioContextIOS() | ||
159 | + )); | ||
154 | await audioPlayer.setBalance(0.0); | 160 | await audioPlayer.setBalance(0.0); |
155 | add(OnXSVoiceStateChangeEvent()); | 161 | add(OnXSVoiceStateChangeEvent()); |
156 | return; | 162 | return; |
@@ -159,6 +165,9 @@ class ReadingPageBloc | @@ -159,6 +165,9 @@ class ReadingPageBloc | ||
159 | if (call.method == 'voiceFail') { | 165 | if (call.method == 'voiceFail') { |
160 | //评测失败 | 166 | //评测失败 |
161 | _isRecording = false; | 167 | _isRecording = false; |
168 | + await audioPlayer.setAudioContext(const AudioContext( | ||
169 | + iOS: AudioContextIOS() | ||
170 | + )); | ||
162 | await audioPlayer.setBalance(0.0); | 171 | await audioPlayer.setBalance(0.0); |
163 | EasyLoading.showToast('评测失败'); | 172 | EasyLoading.showToast('评测失败'); |
164 | return; | 173 | return; |
@@ -279,7 +288,9 @@ class ReadingPageBloc | @@ -279,7 +288,9 @@ class ReadingPageBloc | ||
279 | 288 | ||
280 | Future<void> _playAudio(String? audioUrl) async { | 289 | Future<void> _playAudio(String? audioUrl) async { |
281 | if (audioUrl!.isNotEmpty) { | 290 | if (audioUrl!.isNotEmpty) { |
282 | - await audioPlayer.play(UrlSource(audioUrl)); | 291 | + await audioPlayer.play(UrlSource(audioUrl), |
292 | + balance: 0.0, ctx: const AudioContext() | ||
293 | + ); | ||
283 | } | 294 | } |
284 | } | 295 | } |
285 | 296 |