From a0bbff8c687e61b0840424d83315ab989fc96497 Mon Sep 17 00:00:00 2001 From: wuqifeng <540416539@qq.com> Date: Sun, 4 Aug 2024 14:27:37 +0800 Subject: [PATCH] feat:代码优化-背景音播放使用await同步阻塞 --- lib/pages/home/view.dart | 4 ++-- lib/pages/section/section_page.dart | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 1ecf2ae..7f44a0a 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -79,7 +79,7 @@ class _HomePageView extends StatelessWidget { child: GestureDetector( onTap: () { _checkPermission(() async { - clickController.playMusicAndPerformAction( + await clickController.playMusicAndPerformAction( context, AudioPlayerUtilType.classTime, () async { pushNamed(AppRouteName.courseUnit) @@ -172,7 +172,7 @@ class _HomePageView extends StatelessWidget { return GestureDetector( onTap: () { _checkPermission(() async { - clickController.playMusicAndPerformAction( + await clickController.playMusicAndPerformAction( context, AudioPlayerUtilType.gameTime, () async { pushNamed(AppRouteName.games) diff --git a/lib/pages/section/section_page.dart b/lib/pages/section/section_page.dart index f2d32d4..282dfd4 100644 --- a/lib/pages/section/section_page.dart +++ b/lib/pages/section/section_page.dart @@ -77,7 +77,7 @@ class _SectionPageView extends StatelessWidget { audioType = AudioPlayerUtilType.videoTime; } - clickController.playMusicAndPerformAction(context, audioType, + await clickController.playMusicAndPerformAction(context, audioType, () async { ///播放音乐->调进入课程接口->跳转课程页面 await bloc.requestEnterClass(courseLessonId, () { @@ -108,7 +108,7 @@ class _SectionPageView extends StatelessWidget { if (courseType == SectionType.pictureBook.value) { //绘本 - clickController.playMusicAndPerformAction( + await clickController.playMusicAndPerformAction( context, AudioPlayerUtilType.readingTime, () async { await bloc.requestEnterClass(courseLessonId, () { pushNamed(AppRouteName.reading, @@ -134,7 +134,7 @@ class _SectionPageView extends StatelessWidget { if (courseType == SectionType.practice.value) { //练习 - clickController.playMusicAndPerformAction( + await clickController.playMusicAndPerformAction( context, AudioPlayerUtilType.quizTime, () async { await bloc.requestEnterClass(courseLessonId, () { pushNamed(AppRouteName.topicPic, arguments: { -- libgit2 0.22.2