Playback: Always remember last playing track

Select it on startup, and start playback at the last position if
configured to do so. Also, if there is a bug and multiple tracks are
marked for current, unmark them as usual, but also commit the changes.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-07-12 02:45:18 -07:00
parent 6b047c0acf
commit f549465a4f

View file

@ -247,14 +247,11 @@ static BOOL consentLastEnabled = NO;
if(results && [results count] > 0) {
PlaylistEntry *pe = results[0];
// Select this track
[playlistView selectRowIndexes:[NSIndexSet indexSetWithIndex:pe.index] byExtendingSelection:NO];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"resumePlaybackOnStartup"]) {
// And play it
[playbackController playEntryAtIndex:pe.index startPaused:(lastStatus == CogStatusPaused) andSeekTo:@(pe.currentPosition)];
} else {
pe.current = NO;
pe.stopAfter = NO;
pe.currentPosition = 0.0;
pe.countAdded = NO;
[playlistController commitPersistentStore];
}
// Bug fix
if([results count] > 1) {
@ -262,6 +259,7 @@ static BOOL consentLastEnabled = NO;
PlaylistEntry *pe = results[i];
[pe setCurrent:NO];
}
[playlistController commitPersistentStore];
}
}
}