From f549465a4f784534c9f39986a185e5f514515bee Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 12 Jul 2025 02:45:18 -0700 Subject: [PATCH] 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 --- Application/AppController.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Application/AppController.m b/Application/AppController.m index 3c5c15955..969b62213 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -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]; } } }