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 | 130 | "setMethodCallHandler method=${call.method} arguments=${call.arguments}"); |
131 | 131 | if (call.method == 'voiceResult') { |
132 | 132 | //评测结果 |
133 | + await audioPlayer.setAudioContext(const AudioContext( | |
134 | + iOS: AudioContextIOS() | |
135 | + )); | |
133 | 136 | await audioPlayer.setBalance(0.0); |
134 | 137 | add(XSVoiceResultEvent(call.arguments)); |
135 | 138 | return; |
... | ... | @@ -151,6 +154,9 @@ class ReadingPageBloc |
151 | 154 | print(call.method == 'voiceEnd' ? '评测结束' : '评测取消'); |
152 | 155 | } |
153 | 156 | _isRecording = false; |
157 | + await audioPlayer.setAudioContext(const AudioContext( | |
158 | + iOS: AudioContextIOS() | |
159 | + )); | |
154 | 160 | await audioPlayer.setBalance(0.0); |
155 | 161 | add(OnXSVoiceStateChangeEvent()); |
156 | 162 | return; |
... | ... | @@ -159,6 +165,9 @@ class ReadingPageBloc |
159 | 165 | if (call.method == 'voiceFail') { |
160 | 166 | //评测失败 |
161 | 167 | _isRecording = false; |
168 | + await audioPlayer.setAudioContext(const AudioContext( | |
169 | + iOS: AudioContextIOS() | |
170 | + )); | |
162 | 171 | await audioPlayer.setBalance(0.0); |
163 | 172 | EasyLoading.showToast('评测失败'); |
164 | 173 | return; |
... | ... | @@ -279,7 +288,9 @@ class ReadingPageBloc |
279 | 288 | |
280 | 289 | Future<void> _playAudio(String? audioUrl) async { |
281 | 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 | ... | ... |