Commit 77d53ec4f9ea538375013a782b4229e9a270258a
1 parent
0529078d
feat:练习音效控制优化
Showing
1 changed file
with
13 additions
and
6 deletions
lib/pages/practice/bloc/topic_picture_bloc.dart
@@ -92,11 +92,14 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | @@ -92,11 +92,14 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | ||
92 | _isResultSoundPlaying = false; | 92 | _isResultSoundPlaying = false; |
93 | if (_forbiddenWhenCorrect) { | 93 | if (_forbiddenWhenCorrect) { |
94 | _forbiddenWhenCorrect = false; | 94 | _forbiddenWhenCorrect = false; |
95 | - // 答对后自动翻页 | ||
96 | - pageController.nextPage( | ||
97 | - duration: const Duration(milliseconds: 500), | ||
98 | - curve: Curves.ease, | ||
99 | - ); | 95 | + debugPrint('播放完成后解除禁止'); |
96 | + if (event == PlayerState.completed) { | ||
97 | + // 答对后且播放完自动翻页 | ||
98 | + pageController.nextPage( | ||
99 | + duration: const Duration(milliseconds: 500), | ||
100 | + curve: Curves.ease, | ||
101 | + ); | ||
102 | + } | ||
100 | } | 103 | } |
101 | } | 104 | } |
102 | } else { | 105 | } else { |
@@ -286,7 +289,11 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | @@ -286,7 +289,11 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | ||
286 | } | 289 | } |
287 | 290 | ||
288 | void _playResultSound(bool isCorrect) async { | 291 | void _playResultSound(bool isCorrect) async { |
289 | - await audioPlayer.stop(); | 292 | + // await audioPlayer.stop(); |
293 | + if (audioPlayer.state == PlayerState.playing && _isResultSoundPlaying == false) { | ||
294 | + _voicePlayState = VoicePlayState.stop; | ||
295 | + } | ||
296 | + debugPrint("_playResultSound isCorrect=$isCorrect"); | ||
290 | _isResultSoundPlaying = true; | 297 | _isResultSoundPlaying = true; |
291 | _forbiddenWhenCorrect = isCorrect; | 298 | _forbiddenWhenCorrect = isCorrect; |
292 | if (isCorrect) { | 299 | if (isCorrect) { |