From a434ef7b2e9406f23089ad20eebd3fa7d2f8408c Mon Sep 17 00:00:00 2001 From: lcy <2503978335@qq.com> Date: Thu, 20 Jul 2023 09:16:46 +0800 Subject: [PATCH] feat:修复绘本页闪退问题 --- assets/images/photo_pause.png | Bin 311675 -> 0 bytes lib/pages/reading/bloc/reading_bloc.dart | 11 +++++------ lib/pages/reading/reading_page.dart | 10 ++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/assets/images/photo_pause.png b/assets/images/photo_pause.png index a339e26..d1cca72 100644 Binary files a/assets/images/photo_pause.png and b/assets/images/photo_pause.png differ diff --git a/lib/pages/reading/bloc/reading_bloc.dart b/lib/pages/reading/bloc/reading_bloc.dart index 071c33c..a73d087 100644 --- a/lib/pages/reading/bloc/reading_bloc.dart +++ b/lib/pages/reading/bloc/reading_bloc.dart @@ -90,20 +90,16 @@ class ReadingPageBloc extends Bloc { //音频播放器 audioPlayer = AudioPlayer(); audioPlayer.onPlayerStateChanged.listen((event) async { - debugPrint('播放状态变化'); if (event == PlayerState.completed) { - debugPrint('播放完成'); _voicePlayState = VoicePlayState.completed; _onAudioPlayComplete(); } if (event == PlayerState.stopped) { - debugPrint('播放结束'); _voicePlayState = VoicePlayState.stop; _onAudioPlayComplete(); } if (event == PlayerState.playing) { - debugPrint('正在播放中'); _voicePlayState = VoicePlayState.playing; } if (isClosed) { @@ -261,6 +257,9 @@ class ReadingPageBloc extends Bloc { } CourseProcessReadings? currentPageData() { + if ((_entity?.readings?.length??0) - 1 < _currentPage) { + return null; + } return _entity?.readings?[_currentPage]; } @@ -338,7 +337,7 @@ class ReadingPageBloc extends Bloc { nextPage(); } - Log.d("_onAudioPlayComplete _isOriginAudioPlaying=${_isOriginAudioPlaying} _voicePlayState=$_voicePlayState recordUrl=${currentPageData()?.recordUrl?.isNotEmpty}"); + Log.d("_onAudioPlayComplete _isOriginAudioPlaying=$_isOriginAudioPlaying _voicePlayState=$_voicePlayState recordUrl=${currentPageData()?.recordUrl?.isNotEmpty}"); if (_isOriginAudioPlaying && _voicePlayState == VoicePlayState.completed && currentPageData()?.recordUrl?.isNotEmpty != true) { ///如果刚刚完成原音播放&&录音为空,则开始录音 startRecord(currentPageData()?.word ?? ''); @@ -358,7 +357,7 @@ class ReadingPageBloc extends Bloc { OnXSVoiceStateChangeEvent event, Emitter emitter ) async { - emit(XSVoiceTestState()); + emitter(XSVoiceTestState()); } } diff --git a/lib/pages/reading/reading_page.dart b/lib/pages/reading/reading_page.dart index fcd0b55..0026718 100644 --- a/lib/pages/reading/reading_page.dart +++ b/lib/pages/reading/reading_page.dart @@ -118,8 +118,7 @@ class _ReadingPage extends StatelessWidget { ), Padding( - padding: EdgeInsets.only( - right: 15.w + ScreenUtil().bottomBarHeight), + padding: EdgeInsets.only(right: 15.w + ScreenUtil().bottomBarHeight), child: GestureDetector( onTap: () { bloc.add(CurrentModeChangeEvent()); @@ -233,13 +232,12 @@ class _ReadingPage extends StatelessWidget { ); }); - Widget _readingPagerItem(CourseProcessReadings readings) => - BlocBuilder(builder: (context, state) { + Widget _readingPagerItem(CourseProcessReadings readings) => BlocBuilder( + builder: (context, state) { return Stack( children: [ Positioned.fill( - child: - Image.network(readings.picUrl ?? '', fit: BoxFit.cover), + child: Image.network(readings.picUrl ?? '', fit: BoxFit.cover), ), ], ); -- libgit2 0.22.2