Commit a0bbff8c687e61b0840424d83315ab989fc96497
1 parent
4fb9cd24
feat:代码优化-背景音播放使用await同步阻塞
Showing
2 changed files
with
5 additions
and
5 deletions
lib/pages/home/view.dart
@@ -79,7 +79,7 @@ class _HomePageView extends StatelessWidget { | @@ -79,7 +79,7 @@ class _HomePageView extends StatelessWidget { | ||
79 | child: GestureDetector( | 79 | child: GestureDetector( |
80 | onTap: () { | 80 | onTap: () { |
81 | _checkPermission(() async { | 81 | _checkPermission(() async { |
82 | - clickController.playMusicAndPerformAction( | 82 | + await clickController.playMusicAndPerformAction( |
83 | context, AudioPlayerUtilType.classTime, | 83 | context, AudioPlayerUtilType.classTime, |
84 | () async { | 84 | () async { |
85 | pushNamed(AppRouteName.courseUnit) | 85 | pushNamed(AppRouteName.courseUnit) |
@@ -172,7 +172,7 @@ class _HomePageView extends StatelessWidget { | @@ -172,7 +172,7 @@ class _HomePageView extends StatelessWidget { | ||
172 | return GestureDetector( | 172 | return GestureDetector( |
173 | onTap: () { | 173 | onTap: () { |
174 | _checkPermission(() async { | 174 | _checkPermission(() async { |
175 | - clickController.playMusicAndPerformAction( | 175 | + await clickController.playMusicAndPerformAction( |
176 | context, AudioPlayerUtilType.gameTime, | 176 | context, AudioPlayerUtilType.gameTime, |
177 | () async { | 177 | () async { |
178 | pushNamed(AppRouteName.games) | 178 | pushNamed(AppRouteName.games) |
lib/pages/section/section_page.dart
@@ -77,7 +77,7 @@ class _SectionPageView extends StatelessWidget { | @@ -77,7 +77,7 @@ class _SectionPageView extends StatelessWidget { | ||
77 | audioType = AudioPlayerUtilType.videoTime; | 77 | audioType = AudioPlayerUtilType.videoTime; |
78 | } | 78 | } |
79 | 79 | ||
80 | - clickController.playMusicAndPerformAction(context, audioType, | 80 | + await clickController.playMusicAndPerformAction(context, audioType, |
81 | () async { | 81 | () async { |
82 | ///播放音乐->调进入课程接口->跳转课程页面 | 82 | ///播放音乐->调进入课程接口->跳转课程页面 |
83 | await bloc.requestEnterClass(courseLessonId, () { | 83 | await bloc.requestEnterClass(courseLessonId, () { |
@@ -108,7 +108,7 @@ class _SectionPageView extends StatelessWidget { | @@ -108,7 +108,7 @@ class _SectionPageView extends StatelessWidget { | ||
108 | 108 | ||
109 | if (courseType == SectionType.pictureBook.value) { | 109 | if (courseType == SectionType.pictureBook.value) { |
110 | //绘本 | 110 | //绘本 |
111 | - clickController.playMusicAndPerformAction( | 111 | + await clickController.playMusicAndPerformAction( |
112 | context, AudioPlayerUtilType.readingTime, () async { | 112 | context, AudioPlayerUtilType.readingTime, () async { |
113 | await bloc.requestEnterClass(courseLessonId, () { | 113 | await bloc.requestEnterClass(courseLessonId, () { |
114 | pushNamed(AppRouteName.reading, | 114 | pushNamed(AppRouteName.reading, |
@@ -134,7 +134,7 @@ class _SectionPageView extends StatelessWidget { | @@ -134,7 +134,7 @@ class _SectionPageView extends StatelessWidget { | ||
134 | 134 | ||
135 | if (courseType == SectionType.practice.value) { | 135 | if (courseType == SectionType.practice.value) { |
136 | //练习 | 136 | //练习 |
137 | - clickController.playMusicAndPerformAction( | 137 | + await clickController.playMusicAndPerformAction( |
138 | context, AudioPlayerUtilType.quizTime, () async { | 138 | context, AudioPlayerUtilType.quizTime, () async { |
139 | await bloc.requestEnterClass(courseLessonId, () { | 139 | await bloc.requestEnterClass(courseLessonId, () { |
140 | pushNamed(AppRouteName.topicPic, arguments: { | 140 | pushNamed(AppRouteName.topicPic, arguments: { |