Live Activities, nudging, unit tests

This commit is contained in:
2026-04-20 11:11:24 +02:00
parent 3858500a45
commit 7e25a4f978
15 changed files with 348 additions and 20 deletions
@@ -149,6 +149,11 @@ final class MAPlayerManager {
/// Finds the best currently-playing player and pushes its state to the Live Activity.
/// Spawns a Task to fetch artwork with auth before updating.
private func updateLiveActivity() {
guard UserDefaults.standard.object(forKey: "liveActivityEnabled") as? Bool ?? true else {
liveActivityManager.end()
return
}
let playing = players.values
.filter { $0.state == .playing }
.first { $0.currentItem != nil || playerQueues[$0.playerId]?.currentItem != nil }
@@ -248,6 +253,9 @@ final class MAPlayerManager {
}
}
/// Exposed for unit testing only.
static func testResizeAndEncode(_ image: UIImage) -> Data? { resizeAndEncode(image) }
private static func resizeAndEncode(_ image: UIImage) -> Data? {
// ActivityKit ContentState limit is 4 KB total (Data fields are base64 in the payload).
// 40×40 JPEG at 0.3 quality 400700 bytes, well within limits.