Player: new setting to optionally save and use song playback progress

This commit is contained in:
Maximilian Bauer
2025-12-18 19:07:42 +01:00
parent 96a29f547b
commit 84e740db9e
6 changed files with 17 additions and 10 deletions

View File

@@ -207,6 +207,10 @@ class SettingsHostVC: UIViewController {
changesAgent.append(settings.$isPlaybackStartOnlyOnPlay.sink(receiveValue: { newValue in
self.appDelegate.storage.settings.user.isPlaybackStartOnlyOnPlay = newValue
}))
settings.isPlayerSongPlaybackResumeEnabled = appDelegate.storage.settings.user.isPlayerSongPlaybackResumeEnabled
changesAgent.append(settings.$isPlayerSongPlaybackResumeEnabled.sink(receiveValue: { newValue in
self.appDelegate.storage.settings.user.isPlayerSongPlaybackResumeEnabled = newValue
}))
settings.swipeActionSettings = appDelegate.storage.settings.user.swipeActionSettings

View File

@@ -59,6 +59,8 @@ final class Settings: ObservableObject {
@Published
var isPlaybackStartOnlyOnPlay = false
@Published
var isPlayerSongPlaybackResumeEnabled = false
@Published
var isShowMusicPlayerSkipButtons = false
@Published
var isLyricsSmoothScrolling = true

View File

@@ -105,6 +105,10 @@ struct PlayerSettingsView: View {
footer: "Enable to scrobble all streamed songs, even if the server already marks them as played."
)
SettingsSection(content: {
SettingsCheckBoxRow(title: "Song Playback Resume", isOn: $settings.isPlayerSongPlaybackResumeEnabled)
}, footer: "Keeps track of song progress so playback continues from the previously saved position.")
SettingsSection(content: {
SettingsCheckBoxRow(title: "Manual Playback", isOn: $settings.isPlaybackStartOnlyOnPlay)
}, footer: "Enable to start playback only when the Play button is pressed.")

View File

@@ -43,7 +43,6 @@ public class AudioPlayer: NSObject, BackendAudioPlayerNotifiable {
}
var isShouldPauseAfterFinishedPlaying = false
private var isContinueSongProgress = true
private var playerStatus: PlayerStatusPersistent
private var queueHandler: PlayQueueHandler
@@ -175,7 +174,6 @@ public class AudioPlayer: NSObject, BackendAudioPlayerNotifiable {
stop()
return
}
isContinueSongProgress = false
insertIntoPlayer(playable: playable)
}
@@ -231,7 +229,6 @@ public class AudioPlayer: NSObject, BackendAudioPlayerNotifiable {
// BackendAudioPlayerNotifiable
func stop() {
isContinueSongProgress = false
backendAudioPlayer.stop()
playerStatus.stop()
notifyPlayerStopped()
@@ -242,10 +239,6 @@ public class AudioPlayer: NSObject, BackendAudioPlayerNotifiable {
notifyPlayerStopped()
}
func activateSongContinueProgress() {
isContinueSongProgress = true
}
func togglePlayPause() {
if backendAudioPlayer.isPlaying {
pause()
@@ -257,10 +250,9 @@ public class AudioPlayer: NSObject, BackendAudioPlayerNotifiable {
private func seekToLastStoppedPlayTime() {
if let playable = currentlyPlaying,
playable.playProgress > 0,
backendAudioPlayer.isErrorOccurred || playable.isPodcastEpisode || isContinueSongProgress {
playable.isPodcastEpisode || ((playable.isSong || backendAudioPlayer.isErrorOccurred) && settings.user.isPlayerSongPlaybackResumeEnabled) {
backendAudioPlayer.seek(toSecond: Double(playable.playProgress))
}
isContinueSongProgress = false
}
// BackendAudioPlayerNotifiable

View File

@@ -488,7 +488,6 @@ class PlayerFacadeImpl: PlayerFacade {
musicPlayer.stopButRemainIndex()
playerStatus.setPlayerMode(newValue)
musicPlayer.notifyPlaylistUpdated()
musicPlayer.activateSongContinueProgress()
}
var streamingMaxBitrates: StreamingMaxBitrates { backendAudioPlayer.streamingMaxBitrates }

View File

@@ -152,6 +152,12 @@ public struct UserSettings: Sendable, Codable {
get { _isPlaybackStartOnlyOnPlay }
set { _isPlaybackStartOnlyOnPlay = newValue }
}
private var _isPlayerSongPlaybackResumeEnabled: Bool = false
public var isPlayerSongPlaybackResumeEnabled: Bool {
get { _isPlayerSongPlaybackResumeEnabled }
set { _isPlayerSongPlaybackResumeEnabled = newValue }
}
private var _isHapticsEnabled: Bool = true
public var isHapticsEnabled: Bool {