Commit cacfac41596f9fb3685f90daa1a05ce1223cab29
1 parent
6051f850
feat:修复视频跟读页无法录音问题
Showing
2 changed files
with
7 additions
and
8 deletions
lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart
| ... | ... | @@ -104,24 +104,21 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | ///初始化功能 |
| 107 | - void _initBlocData(InitBlocEvent event, Emitter<RepeatAfterContentState> emitter) { | |
| 107 | + void _initBlocData(InitBlocEvent event, Emitter<RepeatAfterContentState> emitter) async { | |
| 108 | 108 | methodChannel = const MethodChannel('wow_english/sing_sound_method_channel'); |
| 109 | 109 | methodChannel.setMethodCallHandler((call) async { |
| 110 | 110 | if (call.method == 'voiceResult') {//评测结果 |
| 111 | 111 | add(XSVoiceResultEvent(call.arguments)); |
| 112 | 112 | add(PostFollowReadContentEvent()); |
| 113 | - return; | |
| 114 | 113 | } |
| 115 | 114 | }); |
| 116 | 115 | |
| 117 | 116 | //录音 |
| 118 | 117 | _soundRecorder = FlutterSoundRecorder(); |
| 119 | - _init(); | |
| 120 | - } | |
| 121 | 118 | |
| 122 | - void _init() async { | |
| 119 | + | |
| 123 | 120 | await _soundRecorder.openRecorder(); |
| 124 | - await _soundRecorder.setSubscriptionDuration(const Duration(milliseconds: 10)); | |
| 121 | + // await _soundRecorder.setSubscriptionDuration(const Duration(milliseconds: 10)); | |
| 125 | 122 | |
| 126 | 123 | //音屏 |
| 127 | 124 | _soundPlayer = FlutterSoundPlayer(); |
| ... | ... | @@ -146,7 +143,7 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo |
| 146 | 143 | )); |
| 147 | 144 | await _soundPlayer.closePlayer(); |
| 148 | 145 | await _soundPlayer.openPlayer(); |
| 149 | - await _soundPlayer.setSubscriptionDuration(const Duration(milliseconds: 10)); | |
| 146 | + // await _soundPlayer.setSubscriptionDuration(const Duration(milliseconds: 10)); | |
| 150 | 147 | } |
| 151 | 148 | |
| 152 | 149 | ///请求数据 |
| ... | ... | @@ -199,7 +196,7 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo |
| 199 | 196 | |
| 200 | 197 | ///先声测试 |
| 201 | 198 | void _voiceXsTest(XSVoiceTestEvent event,Emitter<RepeatAfterContentState> emitter) async { |
| 202 | - methodChannel.invokeMethod( | |
| 199 | + await methodChannel.invokeMethod( | |
| 203 | 200 | 'starLocalVoice', |
| 204 | 201 | { |
| 205 | 202 | 'type':event.type, | ... | ... |
lib/pages/repeataftercontent/repeat_after_content_page.dart
| ... | ... | @@ -256,6 +256,7 @@ class _RepeatAfterContentPage extends StatelessWidget { |
| 256 | 256 | mainAxisAlignment: MainAxisAlignment.end, |
| 257 | 257 | children: [ |
| 258 | 258 | Offstage( |
| 259 | + // offstage: false, | |
| 259 | 260 | offstage:!(bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd && bloc.xSCheckState == XSVoiceCheckState.stop), |
| 260 | 261 | child: Column( |
| 261 | 262 | children: [ |
| ... | ... | @@ -298,6 +299,7 @@ class _RepeatAfterContentPage extends StatelessWidget { |
| 298 | 299 | ), |
| 299 | 300 | ), |
| 300 | 301 | Offstage( |
| 302 | + // offstage: true, | |
| 301 | 303 | offstage: bloc.voiceRecordState == VoiceRecordState.voiceRecordUnkonw || bloc.xSCheckState != XSVoiceCheckState.unKnow, |
| 302 | 304 | child: Container( |
| 303 | 305 | color: Colors.grey, | ... | ... |