Commit 0e314ad506eb74c15af1065bb50507524741e1ce
1 parent
dae2a16e
feat:开屏页播放背景音乐welcome wow english
Showing
4 changed files
with
15 additions
and
10 deletions
lib/app/splash_page.dart
... | ... | @@ -14,6 +14,7 @@ import 'package:wow_english/common/request/config.dart'; |
14 | 14 | import 'package:wow_english/common/request/dao/user_dao.dart'; |
15 | 15 | import 'package:wow_english/models/user_entity.dart'; |
16 | 16 | import 'package:wow_english/route/route.dart'; |
17 | +import 'package:wow_english/utils/audio_player_util.dart'; | |
17 | 18 | import 'package:wow_english/utils/log_util.dart'; |
18 | 19 | import 'package:wow_english/utils/sp_util.dart'; |
19 | 20 | |
... | ... | @@ -58,7 +59,8 @@ class _TransitionViewState extends State<TransitionView> { |
58 | 59 | await fetchNecessaryData(token); |
59 | 60 | apartInMilliseconds = DateTime.now().difference(startTime).inMilliseconds; |
60 | 61 | } |
61 | - int duration = max(2000 - apartInMilliseconds, 0); | |
62 | + /// 开屏最低2.5s,保证视觉与音乐同步 | |
63 | + int duration = max(2500 - apartInMilliseconds, 0); | |
62 | 64 | Log.d('Splash getUserInfo 耗时:${apartInMilliseconds}ms, 最终duration=$duration'); |
63 | 65 | Timer(Duration(milliseconds: duration), () { |
64 | 66 | /*if (userEntity != null) { |
... | ... | @@ -163,9 +165,10 @@ class _TransitionViewState extends State<TransitionView> { |
163 | 165 | } |
164 | 166 | |
165 | 167 | void init() async { |
168 | + changeDevice(); | |
166 | 169 | await SpUtil.preInit(); |
170 | + AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.welcomeToWow); | |
167 | 171 | startTime(); |
168 | - changeDevice(); | |
169 | 172 | } |
170 | 173 | |
171 | 174 | void changeDevice() async { | ... | ... |
lib/pages/home/bloc.dart
1 | -import 'package:audioplayers/audioplayers.dart'; | |
1 | +import 'dart:async'; | |
2 | + | |
2 | 3 | import 'package:bloc/bloc.dart'; |
3 | 4 | import 'package:wow_english/common/core/user_util.dart'; |
4 | -import 'package:wow_english/common/extension/string_extension.dart'; | |
5 | 5 | import 'package:wow_english/utils/audio_player_util.dart'; |
6 | 6 | |
7 | 7 | import '../../common/core/app_config_helper.dart'; |
... | ... | @@ -21,7 +21,10 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> { |
21 | 21 | |
22 | 22 | void _init(InitEvent event, Emitter<HomeState> emit) async { |
23 | 23 | if (UserUtil.isLogined()) { |
24 | - AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.welcomeToWow); | |
24 | + /// 增加1s避免与开屏音乐撞车(覆盖) | |
25 | + Timer(const Duration(seconds: 1), () { | |
26 | + AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.touch); | |
27 | + }); | |
25 | 28 | } |
26 | 29 | await _checkUpdate(emit); |
27 | 30 | } | ... | ... |
lib/pages/home/widgets/ShakeImage.dart
... | ... | @@ -38,9 +38,11 @@ class _ShakeImageState extends State<ShakeImage> with SingleTickerProviderStateM |
38 | 38 | TweenSequenceItem(tween: Tween(begin: -0.05, end: 0.0).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), |
39 | 39 | ]).animate(_controller); |
40 | 40 | |
41 | - _controller.forward(from: 0.0); | |
42 | - _timer = Timer.periodic(const Duration(seconds: 4), (Timer timer) { | |
41 | + Timer(const Duration(seconds: 1), () { | |
43 | 42 | _controller.forward(from: 0.0); |
43 | + _timer = Timer.periodic(const Duration(seconds: 4), (Timer timer) { | |
44 | + _controller.forward(from: 0.0); | |
45 | + }); | |
44 | 46 | }); |
45 | 47 | |
46 | 48 | // _controller.addStatusListener((status) { | ... | ... |
lib/utils/audio_player_util.dart
... | ... | @@ -44,9 +44,6 @@ class AudioPlayerUtil extends WidgetsBindingObserver { |
44 | 44 | AudioPlayerUtil.getInstance() |
45 | 45 | .playAudio(AudioPlayerUtilType.countWithMe); |
46 | 46 | } |
47 | - if (currentType == AudioPlayerUtilType.welcomeToWow) { | |
48 | - AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.touch); | |
49 | - } | |
50 | 47 | if (currentType == AudioPlayerUtilType.touch) { |
51 | 48 | AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.touch); |
52 | 49 | } | ... | ... |