Merge branch 'timer-fix' into 'Timer-popup'

enable timer to replay music

See merge request Crondung/hsma_cpd!8
main
Parricc35 2023-02-23 17:05:18 +00:00
commit aeeca1d2b7
1 changed files with 7 additions and 5 deletions

View File

@ -59,9 +59,9 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
void _resetTimer() { void _resetTimer() {
() async { () async {
await coolDownPlayer.dispose(); await coolDownPlayer.stop();
await warmUpPlayer.dispose(); await warmUpPlayer.stop();
await workoutPlayer.dispose(); await workoutPlayer.stop();
}(); }();
_isPaused = true; _isPaused = true;
_timer?.cancel(); _timer?.cancel();
@ -85,8 +85,9 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
} }
Future<void> _playWorkoutMusic() async { Future<void> _playWorkoutMusic() async {
await warmUpPlayer.dispose(); await warmUpPlayer.stop();
Future.delayed(const Duration(microseconds: 600)).then((value) async { Future.delayed(const Duration(microseconds: 600)).then((value) async {
await workoutPlayer.setReleaseMode(ReleaseMode.loop);
await workoutPlayer.play(UrlSource('assets/workout.mp3')); await workoutPlayer.play(UrlSource('assets/workout.mp3'));
}); });
} }
@ -121,7 +122,8 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
_currentBlock++; _currentBlock++;
_currentDuration = _cooldownDuration; _currentDuration = _cooldownDuration;
() async { () async {
await workoutPlayer.dispose(); await workoutPlayer.stop();
await coolDownPlayer.setReleaseMode(ReleaseMode.loop);
await coolDownPlayer.play(UrlSource('assets/cool_down.mp3')); await coolDownPlayer.play(UrlSource('assets/cool_down.mp3'));
}(); }();
} else { } else {