From 9d7ba55183ba5d19b5fdf0be00e500bfbb5ff387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Kr=C3=A4mer?= Date: Sat, 21 Dec 2024 09:48:31 +0100 Subject: [PATCH] Remive debug code --- Multiplatform/Account/AccountSheet.swift | 19 ------ Multiplatform/Localizable.xcstrings | 6 -- .../Modifiers/ContextMenuModifier.swift | 2 +- .../SPPlayback/AudioPlayer+Observers.swift | 4 +- .../SPPlayback/AudioPlayer+Playback.swift | 10 ++- .../SPPlayback/AudioPlayer+Queue.swift | 2 +- .../SleepTimer/SleepTimer+Events.swift | 6 -- .../Sources/SPPlayback/tmpDebug.swift | 63 ------------------- 8 files changed, 8 insertions(+), 104 deletions(-) delete mode 100644 ShelfPlayerKit/Sources/SPPlayback/tmpDebug.swift diff --git a/Multiplatform/Account/AccountSheet.swift b/Multiplatform/Account/AccountSheet.swift index a6b78457..77ad91fd 100644 --- a/Multiplatform/Account/AccountSheet.swift +++ b/Multiplatform/Account/AccountSheet.swift @@ -39,28 +39,9 @@ internal struct AccountSheet: View { return formatter.string(from: NSNumber(value: customPlaybackSpeed))! } - @State private var stops: [StopEvent] = SPPlayback.stops - var body: some View { NavigationStack { List { - Section { - ForEach(stops, id: \.time) { stop in - VStack { - Text(stop.time, style: .relative) - Text(stop.reason.label) - } - } - - Button("update") { - stops = SPPlayback.stops - } - - Button("clear") { - clearStops() - } - } - Section { if let username { Text(username) diff --git a/Multiplatform/Localizable.xcstrings b/Multiplatform/Localizable.xcstrings index 2ffb8c57..bdea55bc 100644 --- a/Multiplatform/Localizable.xcstrings +++ b/Multiplatform/Localizable.xcstrings @@ -2548,9 +2548,6 @@ } } } - }, - "clear" : { - }, "decrease" : { "localizations" : { @@ -7129,9 +7126,6 @@ } } } - }, - "update" : { - } }, "version" : "1.0" diff --git a/Multiplatform/NowPlaying/Modifiers/ContextMenuModifier.swift b/Multiplatform/NowPlaying/Modifiers/ContextMenuModifier.swift index 76126d87..a1e2b64b 100644 --- a/Multiplatform/NowPlaying/Modifiers/ContextMenuModifier.swift +++ b/Multiplatform/NowPlaying/Modifiers/ContextMenuModifier.swift @@ -89,7 +89,7 @@ internal extension NowPlaying { } Button { - AudioPlayer.shared.stop(.userRequest) + AudioPlayer.shared.stop() } label: { Label("playback.stop", systemImage: "stop.fill") } diff --git a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Observers.swift b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Observers.swift index 9a5e4e88..4bc7f049 100644 --- a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Observers.swift +++ b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Observers.swift @@ -98,7 +98,7 @@ internal extension AudioPlayer { do { try await advance(finished: true) } catch { - stop(.advanceFailed) + stop() } } } @@ -157,7 +157,7 @@ internal extension AudioPlayer { let elapsed = Date().timeIntervalSince(lastPause) if elapsed > timeout { - self.stop(.playerTimeout) + self.stop() } } } diff --git a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Playback.swift b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Playback.swift index 34c0d5bd..7594443d 100644 --- a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Playback.swift +++ b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Playback.swift @@ -16,7 +16,7 @@ import SPOffline public extension AudioPlayer { func play(_ item: PlayableItem, at seconds: TimeInterval? = nil, withoutPlaybackSession: Bool = false) async throws { - stop(.newItem) + stop() try await start(item, at: seconds, withoutPlaybackSession: withoutPlaybackSession) @@ -33,9 +33,7 @@ public extension AudioPlayer { } } - func stop(_ reason: StopReason) { - stops.append(.init(time: .now, reason: reason)) - + func stop() { buffering = true item = nil @@ -80,7 +78,7 @@ public extension AudioPlayer { do { try await advance(finished: true) } catch { - stop(.seekExceededDuration) + stop() } } @@ -183,7 +181,7 @@ internal extension AudioPlayer { } if queue.isEmpty { - stop(.queueEmpty) + stop() return } diff --git a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Queue.swift b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Queue.swift index e5250b7d..2270fb89 100644 --- a/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Queue.swift +++ b/ShelfPlayerKit/Sources/SPPlayback/AudioPlayer+Queue.swift @@ -16,7 +16,7 @@ import SPExtension public extension AudioPlayer { func advance(to index: Int) async throws { guard index < queue.count else { - stop(.queueIndexOutOfBounds) + stop() return } diff --git a/ShelfPlayerKit/Sources/SPPlayback/SleepTimer/SleepTimer+Events.swift b/ShelfPlayerKit/Sources/SPPlayback/SleepTimer/SleepTimer+Events.swift index a519d24d..cb1d810e 100644 --- a/ShelfPlayerKit/Sources/SPPlayback/SleepTimer/SleepTimer+Events.swift +++ b/ShelfPlayerKit/Sources/SPPlayback/SleepTimer/SleepTimer+Events.swift @@ -27,12 +27,6 @@ internal extension SleepTimer { } func didExpire() { - if expiredAt != nil { - stops.append(.init(time: .now, reason: .sleepTime)) - } else { - stops.append(.init(time: .now, reason: .sleepChapter)) - } - expiresAt = nil expiresAtChapterEnd = nil diff --git a/ShelfPlayerKit/Sources/SPPlayback/tmpDebug.swift b/ShelfPlayerKit/Sources/SPPlayback/tmpDebug.swift deleted file mode 100644 index afd8bfa7..00000000 --- a/ShelfPlayerKit/Sources/SPPlayback/tmpDebug.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// tmptest.swift -// ShelfPlayerKit -// -// Created by Rasmus Krämer on 14.12.24. -// - -import Foundation -import Defaults - -public var stops: [StopEvent] = Defaults[.stopReasons] { - didSet { - Defaults[.stopReasons] = stops - } -} - -public struct StopEvent: Codable, Defaults.Serializable { - public let time: Date - public let reason: StopReason -} -public enum StopReason: Codable { - case newItem - case queueEmpty - case seekExceededDuration - case queueIndexOutOfBounds - case playerTimeout - case advanceFailed - case userRequest - - case sleepChapter - case sleepTime - - public var label: String { - switch self { - case .newItem: - "newItem" - case .queueEmpty: - "queueEmpty" - case .seekExceededDuration: - "seekExceededDuration" - case .queueIndexOutOfBounds: - "queueIndexOutOfBounds" - case .playerTimeout: - "playerTimeout" - case .advanceFailed: - "advancedFailed" - case .userRequest: - "userRequest" - case .sleepChapter: - "sleepChapter" - case .sleepTime: - "sleepTime" - } - } -} - -public func clearStops() { - Defaults.reset(.stopReasons) -} - -private extension Defaults.Keys { - static let stopReasons = Key<[StopEvent]>("stopReason", default: []) -}