From a8902b4ee6fa30c008b193cdbeb90891e889a136 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 3 Mar 2025 18:32:01 -0800 Subject: [PATCH] Playback: Implement Always Stop After Current A new menu option under the Control menu, disabled by default, which stops playback after the current track completes. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 2 ++ Base.lproj/MainMenu.xib | 6 ++++++ Playlist/PlaylistController.m | 8 ++++++++ en.lproj/MainMenu.strings | 3 +++ es.lproj/MainMenu.strings | 3 +++ 5 files changed, 22 insertions(+) diff --git a/Application/AppController.m b/Application/AppController.m index 23aa976a0..d630eb4e6 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -657,6 +657,8 @@ static BOOL consentLastEnabled = NO; [userDefaultsValuesDict setObject:@(2) forKey:@"synthDefaultLoopCount"]; [userDefaultsValuesDict setObject:@(44100) forKey:@"synthSampleRate"]; + [userDefaultsValuesDict setObject:@NO forKey:@"alwaysStopAfterCurrent"]; + // Register and sync defaults [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict]; [[NSUserDefaults standardUserDefaults] synchronize]; diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index da61cc836..e3b9f9dc6 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -1882,6 +1882,12 @@ + + + + + + diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index ce909e0e1..1ddb4cfcd 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -1288,6 +1288,10 @@ static void *playlistControllerContext = &playlistControllerContext; } - (PlaylistEntry *)getNextEntry:(PlaylistEntry *)pe ignoreRepeatOne:(BOOL)ignoreRepeatOne { + if(!ignoreRepeatOne && [[NSUserDefaults standardUserDefaults] boolForKey:@"alwaysStopAfterCurrent"]) { + return nil; + } + if(!ignoreRepeatOne && [self repeat] == RepeatModeRepeatOne) { return pe; } @@ -1357,6 +1361,10 @@ static void *playlistControllerContext = &playlistControllerContext; } - (PlaylistEntry *)getPrevEntry:(PlaylistEntry *)pe ignoreRepeatOne:(BOOL)ignoreRepeatOne { + if(!ignoreRepeatOne && [[NSUserDefaults standardUserDefaults] boolForKey:@"alwaysStopAfterCurrent"]) { + return nil; + } + if(!ignoreRepeatOne && [self repeat] == RepeatModeRepeatOne) { return pe; } diff --git a/en.lproj/MainMenu.strings b/en.lproj/MainMenu.strings index 8a59ef0bf..e25767503 100644 --- a/en.lproj/MainMenu.strings +++ b/en.lproj/MainMenu.strings @@ -461,6 +461,9 @@ /* Class = "NSMenuItem"; title = "Stop After Current"; ObjectID = "1895"; */ "1895.title" = "Stop After Current"; +/* Class = "NSMenuItem"; title = "Always Stop After Current"; ObjectID = "y8c-n8-5Uh"; */ +"y8c-n8-5Uh.title" = "Always Stop After Current"; + /* Class = "CocoaBindingsConnection"; ibShadowedIsNilPlaceholder = "Cog"; ObjectID = "1903"; */ "1903.ibShadowedIsNilPlaceholder" = "Cog"; diff --git a/es.lproj/MainMenu.strings b/es.lproj/MainMenu.strings index 0690bd1ca..6f1d5b50b 100644 --- a/es.lproj/MainMenu.strings +++ b/es.lproj/MainMenu.strings @@ -461,6 +461,9 @@ /* Class = "NSMenuItem"; title = "Stop After Current"; ObjectID = "1895"; */ "1895.title" = "Detener después de la pista actual"; +/* Class = "NSMenuItem"; title = "Always Stop After Current"; ObjectID = "y8c-n8-5Uh"; */ +"y8c-n8-5Uh.title" = "Detener siempre al finalizar"; + /* Class = "CocoaBindingsConnection"; ibShadowedIsNilPlaceholder = "Cog"; ObjectID = "1903"; */ "1903.ibShadowedIsNilPlaceholder" = "Cog";