Commit 6b0947ca40abfc92245504b958cccc6af9e6b574
1 parent
dae7f2fd
feat:绘本增加initVoiceSdk(ios需要);页面销毁时取消先声评测
Showing
5 changed files
with
31 additions
and
4 deletions
android/app/src/main/kotlin/com/kouyuxingqiu/wow_english/methodChannels/SingSoungMethodChannel.kt
@@ -44,22 +44,22 @@ class SingSoungMethodChannel(activity: FlutterActivity, flutterEngine: FlutterEn | @@ -44,22 +44,22 @@ class SingSoungMethodChannel(activity: FlutterActivity, flutterEngine: FlutterEn | ||
44 | } | 44 | } |
45 | "startVoice" -> { | 45 | "startVoice" -> { |
46 | val paramMap = call.arguments as HashMap<String, String> | 46 | val paramMap = call.arguments as HashMap<String, String> |
47 | - Log.d(TAG, "SingSoungMethodChannel startVoice=${call.arguments.javaClass} paramMap=$paramMap") | ||
48 | paramMap["word"]?.let { SingEngineHelper.startRecord(it) } | 47 | paramMap["word"]?.let { SingEngineHelper.startRecord(it) } |
49 | } | 48 | } |
50 | "stopVoice" -> { | 49 | "stopVoice" -> { |
51 | - Log.d(TAG, "SingSoungMethodChannel stopVoice") | ||
52 | SingEngineHelper.stopRecord() | 50 | SingEngineHelper.stopRecord() |
53 | } | 51 | } |
54 | "startLocalVoice" -> { | 52 | "startLocalVoice" -> { |
55 | val paramMap = call.arguments as HashMap<String, String> | 53 | val paramMap = call.arguments as HashMap<String, String> |
56 | - Log.d(TAG, "SingSoungMethodChannel startLocalVoice=${call.arguments.javaClass} paramMap=$paramMap") | ||
57 | paramMap["voicePath"]?.let { voiceFilePath -> | 54 | paramMap["voicePath"]?.let { voiceFilePath -> |
58 | paramMap["word"]?.let { evaluateContent -> | 55 | paramMap["word"]?.let { evaluateContent -> |
59 | SingEngineHelper.evaluate(voiceFilePath, evaluateContent) } | 56 | SingEngineHelper.evaluate(voiceFilePath, evaluateContent) } |
60 | } | 57 | } |
61 | 58 | ||
62 | } | 59 | } |
60 | + "cancelVoice" -> { | ||
61 | + SingEngineHelper.cancel() | ||
62 | + } | ||
63 | else -> { | 63 | else -> { |
64 | result.notImplemented() | 64 | result.notImplemented() |
65 | } | 65 | } |
lib/pages/practice/bloc/topic_picture_bloc.dart
@@ -124,6 +124,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | @@ -124,6 +124,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | ||
124 | pageController.dispose(); | 124 | pageController.dispose(); |
125 | audioPlayer.release(); | 125 | audioPlayer.release(); |
126 | audioPlayer.dispose(); | 126 | audioPlayer.dispose(); |
127 | + _voiceXsCancel(); | ||
127 | return super.close(); | 128 | return super.close(); |
128 | } | 129 | } |
129 | 130 | ||
@@ -195,6 +196,11 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | @@ -195,6 +196,11 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { | ||
195 | methodChannel.invokeMethod('stopVoice'); | 196 | methodChannel.invokeMethod('stopVoice'); |
196 | } | 197 | } |
197 | 198 | ||
199 | + ///取消评测(用于处理退出页面后录音未停止等异常情况的保护操作) | ||
200 | + void _voiceXsCancel() { | ||
201 | + methodChannel.invokeMethod('cancelVoice'); | ||
202 | + } | ||
203 | + | ||
198 | ///先声评测结果 | 204 | ///先声评测结果 |
199 | void _voiceXsResult(XSVoiceResultEvent event,Emitter<TopicPictureState> emitter) async { | 205 | void _voiceXsResult(XSVoiceResultEvent event,Emitter<TopicPictureState> emitter) async { |
200 | final Map args = event.message as Map; | 206 | final Map args = event.message as Map; |
lib/pages/reading/bloc/reading_bloc.dart
@@ -167,6 +167,7 @@ class ReadingPageBloc extends Bloc<ReadingPageEvent, ReadingPageState> { | @@ -167,6 +167,7 @@ class ReadingPageBloc extends Bloc<ReadingPageEvent, ReadingPageState> { | ||
167 | pageController.dispose(); | 167 | pageController.dispose(); |
168 | audioPlayer.release(); | 168 | audioPlayer.release(); |
169 | audioPlayer.dispose(); | 169 | audioPlayer.dispose(); |
170 | + _voiceXsCancel(); | ||
170 | return super.close(); | 171 | return super.close(); |
171 | } | 172 | } |
172 | 173 | ||
@@ -322,6 +323,11 @@ class ReadingPageBloc extends Bloc<ReadingPageEvent, ReadingPageState> { | @@ -322,6 +323,11 @@ class ReadingPageBloc extends Bloc<ReadingPageEvent, ReadingPageState> { | ||
322 | methodChannel.invokeMethod('stopVoice'); | 323 | methodChannel.invokeMethod('stopVoice'); |
323 | } | 324 | } |
324 | 325 | ||
326 | + ///取消评测(用于处理退出页面后录音未停止等异常情况的保护操作) | ||
327 | + void _voiceXsCancel() { | ||
328 | + methodChannel.invokeMethod('cancelVoice'); | ||
329 | + } | ||
330 | + | ||
325 | void _voicePlayStateChange(VoicePlayStateChangeEvent event, | 331 | void _voicePlayStateChange(VoicePlayStateChangeEvent event, |
326 | Emitter<ReadingPageState> emitter) async { | 332 | Emitter<ReadingPageState> emitter) async { |
327 | emitter(VoicePlayStateChange()); | 333 | emitter(VoicePlayStateChange()); |
lib/pages/reading/reading_page.dart
@@ -5,6 +5,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; | @@ -5,6 +5,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; | ||
5 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; | 5 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; |
6 | import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart'; | 6 | import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart'; |
7 | 7 | ||
8 | +import '../../common/core/app_consts.dart'; | ||
8 | import '../../common/core/user_util.dart'; | 9 | import '../../common/core/user_util.dart'; |
9 | import '../../models/course_process_entity.dart'; | 10 | import '../../models/course_process_entity.dart'; |
10 | import '../../utils/log_util.dart'; | 11 | import '../../utils/log_util.dart'; |
@@ -20,7 +21,15 @@ class ReadingPage extends StatelessWidget { | @@ -20,7 +21,15 @@ class ReadingPage extends StatelessWidget { | ||
20 | return BlocProvider( | 21 | return BlocProvider( |
21 | create: (_) => ReadingPageBloc(context, PageController(), courseLessonId ?? '') | 22 | create: (_) => ReadingPageBloc(context, PageController(), courseLessonId ?? '') |
22 | ..add(InitBlocEvent()) | 23 | ..add(InitBlocEvent()) |
23 | - ..add(RequestDataEvent()), | 24 | + ..add(RequestDataEvent()) |
25 | + ..add(XSVoiceInitEvent( | ||
26 | + { | ||
27 | + 'appKey':AppConsts.xsAppKey, | ||
28 | + 'service':AppConsts.xsAppService, | ||
29 | + 'secretKey':AppConsts.xsAppSecretKey, | ||
30 | + 'userId':UserUtil.getUser()!.id.toString(), | ||
31 | + } | ||
32 | + )), | ||
24 | child: _ReadingPage(), | 33 | child: _ReadingPage(), |
25 | ); | 34 | ); |
26 | } | 35 | } |
lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart
@@ -100,6 +100,7 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo | @@ -100,6 +100,7 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo | ||
100 | @override | 100 | @override |
101 | Future<void> close() { | 101 | Future<void> close() { |
102 | _releaseFlauto(); | 102 | _releaseFlauto(); |
103 | + _voiceXsCancel(); | ||
103 | return super.close(); | 104 | return super.close(); |
104 | } | 105 | } |
105 | 106 | ||
@@ -215,6 +216,11 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo | @@ -215,6 +216,11 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo | ||
215 | methodChannel.invokeMethod('stopVoice'); | 216 | methodChannel.invokeMethod('stopVoice'); |
216 | } | 217 | } |
217 | 218 | ||
219 | + ///取消评测(用于处理退出页面后录音未停止等异常情况的保护操作) | ||
220 | + void _voiceXsCancel() { | ||
221 | + methodChannel.invokeMethod('cancelVoice'); | ||
222 | + } | ||
223 | + | ||
218 | ///先声评测结果 | 224 | ///先声评测结果 |
219 | void _voiceXsResult(XSVoiceResultEvent event,Emitter<RepeatAfterContentState> emitter) async { | 225 | void _voiceXsResult(XSVoiceResultEvent event,Emitter<RepeatAfterContentState> emitter) async { |
220 | final Map args = event.message as Map; | 226 | final Map args = event.message as Map; |