diff --git a/lib/screens/player/view.dart b/lib/screens/player/view.dart index 2f2d770..b9cfcd9 100644 --- a/lib/screens/player/view.dart +++ b/lib/screens/player/view.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:math'; import 'package:dismissible_page/dismissible_page.dart'; import 'package:flutter/material.dart'; @@ -164,12 +165,12 @@ class _PlayerScreenState extends State { child: Slider( secondaryTrackValue: _bufferProgress.abs(), value: _draggingValue?.abs() ?? - (_durationCurrent.inMilliseconds <= - _durationTotal.inMilliseconds - ? _durationCurrent.inMilliseconds.toDouble().abs() - : 0), + _durationCurrent.inMilliseconds.toDouble().abs(), min: 0, - max: _durationTotal.inMilliseconds.abs().toDouble(), + max: max( + _durationTotal.inMilliseconds.abs(), + _durationTotal.inMilliseconds.abs(), + ).toDouble(), onChanged: (value) { setState(() => _draggingValue = value); }, @@ -198,6 +199,13 @@ class _PlayerScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + IconButton( + icon: const Icon(Icons.skip_previous), + onPressed: _isFetchingActiveTrack + ? null + : audioPlayer.skipToPrevious, + ), + const Gap(8), SizedBox( width: 56, height: 56, @@ -219,6 +227,12 @@ class _PlayerScreenState extends State { _isFetchingActiveTrack ? null : _togglePlayState, ), ), + const Gap(8), + IconButton( + icon: const Icon(Icons.skip_next), + onPressed: + _isFetchingActiveTrack ? null : audioPlayer.skipToNext, + ), ], ) ], diff --git a/lib/services/audio_player/audio_player.dart b/lib/services/audio_player/audio_player.dart index 80da8d7..7bb4ae4 100755 --- a/lib/services/audio_player/audio_player.dart +++ b/lib/services/audio_player/audio_player.dart @@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart'; import 'package:rhythm_box/platform.dart'; import 'package:rhythm_box/services/local_track.dart'; import 'package:rhythm_box/services/server/server.dart'; +import 'package:rhythm_box/widgets/tracks/querying_track_info.dart'; import 'package:spotify/spotify.dart' hide Playlist; import 'package:rhythm_box/services/audio_player/custom_player.dart'; import 'dart:async'; diff --git a/lib/services/audio_player/audio_player_impl.dart b/lib/services/audio_player/audio_player_impl.dart index 963182f..e102aba 100755 --- a/lib/services/audio_player/audio_player_impl.dart +++ b/lib/services/audio_player/audio_player_impl.dart @@ -89,14 +89,17 @@ class RhythmAudioPlayer extends AudioPlayerInterface int get currentIndex => _mkPlayer.state.playlist.index; Future skipToNext() async { + Get.find().isQueryingTrackInfo.value = true; await _mkPlayer.next(); } Future skipToPrevious() async { + Get.find().isQueryingTrackInfo.value = true; await _mkPlayer.previous(); } Future jumpTo(int index) async { + Get.find().isQueryingTrackInfo.value = true; await _mkPlayer.jump(index); } diff --git a/lib/services/server/sourced_track.dart b/lib/services/server/sourced_track.dart index 3d48544..bf7ad21 100755 --- a/lib/services/server/sourced_track.dart +++ b/lib/services/server/sourced_track.dart @@ -32,7 +32,7 @@ class SourcedTrackProvider extends GetxController { sourcedTrack.value = await SourcedTrack.fetchFromTrack(track: track); - if (isCurrentTrack) query.isQueryingTrackInfo.value = false; + query.isQueryingTrackInfo.value = false; return sourcedTrack.value; } diff --git a/lib/widgets/player/bottom_player.dart b/lib/widgets/player/bottom_player.dart index 91f353f..931cac8 100644 --- a/lib/widgets/player/bottom_player.dart +++ b/lib/widgets/player/bottom_player.dart @@ -163,6 +163,12 @@ class _BottomPlayerState extends State mainAxisAlignment: MainAxisAlignment.end, children: [ IconButton( + icon: const Icon(Icons.skip_next), + onPressed: _isFetchingActiveTrack + ? null + : audioPlayer.skipToNext, + ), + IconButton.filled( icon: _isFetchingActiveTrack ? const SizedBox( height: 20,