diff --git a/lib/pages/reading/bloc/reading_bloc.dart b/lib/pages/reading/bloc/reading_bloc.dart index 754f827..34ac187 100644 --- a/lib/pages/reading/bloc/reading_bloc.dart +++ b/lib/pages/reading/bloc/reading_bloc.dart @@ -130,6 +130,7 @@ class ReadingPageBloc "setMethodCallHandler method=${call.method} arguments=${call.arguments}"); if (call.method == 'voiceResult') { //评测结果 + await audioPlayer.setAudioContext(AudioContext()); await audioPlayer.setBalance(0.0); add(XSVoiceResultEvent(call.arguments)); return; @@ -151,6 +152,7 @@ class ReadingPageBloc print(call.method == 'voiceEnd' ? '评测结束' : '评测取消'); } _isRecording = false; + await audioPlayer.setAudioContext(AudioContext()); await audioPlayer.setBalance(0.0); add(OnXSVoiceStateChangeEvent()); return; @@ -159,6 +161,7 @@ class ReadingPageBloc if (call.method == 'voiceFail') { //评测失败 _isRecording = false; + await audioPlayer.setAudioContext(AudioContext()); await audioPlayer.setBalance(0.0); EasyLoading.showToast('评测失败'); return; @@ -279,7 +282,9 @@ class ReadingPageBloc Future _playAudio(String? audioUrl) async { if (audioUrl!.isNotEmpty) { - await audioPlayer.play(UrlSource(audioUrl)); + await audioPlayer.play(UrlSource(audioUrl), + balance: 0.0, ctx: AudioContext() + ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 12d0e59..2a69920 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -95,7 +95,7 @@ dependencies: # UI适配 https://pub.dev/packages/responsive_framework responsive_framework: ^1.0.0 # 音频播放 https://pub.dev/packages/audioplayers - audioplayers: ^4.1.0 + audioplayers: ^6.0.0 # 语音录制 https://pub.dev/packages/flutter_sound flutter_sound: ^9.2.13 # 音频播放 https://pub.dev/packages/audio_session