mirror of
https://github.com/BLeeEZ/amperfy.git
synced 2025-12-19 08:05:43 +01:00
Player: new setting to optionally save and use song playback progress
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ final class Settings: ObservableObject {
|
||||
@Published
|
||||
var isPlaybackStartOnlyOnPlay = false
|
||||
@Published
|
||||
var isPlayerSongPlaybackResumeEnabled = false
|
||||
@Published
|
||||
var isShowMusicPlayerSkipButtons = false
|
||||
@Published
|
||||
var isLyricsSmoothScrolling = true
|
||||
|
||||
@@ -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.")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -488,7 +488,6 @@ class PlayerFacadeImpl: PlayerFacade {
|
||||
musicPlayer.stopButRemainIndex()
|
||||
playerStatus.setPlayerMode(newValue)
|
||||
musicPlayer.notifyPlaylistUpdated()
|
||||
musicPlayer.activateSongContinueProgress()
|
||||
}
|
||||
|
||||
var streamingMaxBitrates: StreamingMaxBitrates { backendAudioPlayer.streamingMaxBitrates }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user