Skip to content

Commit 118c04b

Browse files
committed
Stopped autofetch from running on the first song in the playlist
1 parent aac8e55 commit 118c04b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

lib/services/media_player.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ class MediaPlayer extends ChangeNotifier {
430430
}
431431

432432
Future<void> playAll(List songs, {int index = 0}) async {
433-
autoFetching = true;
434-
435433
if (songs.isEmpty) return;
436434

435+
autoFetching = true;
436+
437437
_buttonState.value = ButtonState.loading;
438438
notifyListeners();
439439

@@ -451,10 +451,16 @@ class MediaPlayer extends ChangeNotifier {
451451
// Add rest of playlist completely in background (fire and forget)
452452
if (songs.length > 1) {
453453
// Use unawaited to truly run in background
454-
Future(() => _addRemainingToPlaylist(songs, index));
454+
Future(() async {
455+
await _addRemainingToPlaylist(songs, index);
456+
autoFetching = false;
457+
});
458+
}
459+
else {
460+
autoFetching = false;
455461
}
456-
autoFetching = false;
457462
} catch (e) {
463+
autoFetching = false;
458464
print('Error in playAll: $e');
459465
_buttonState.value = ButtonState.paused;
460466
notifyListeners();

0 commit comments

Comments
 (0)