Fix remote player SDK types and signing prefix; test remote commands

This commit is contained in:
2026-09-14 00:48:25 +03:00
parent e2902e6031
commit eaf091b1cf
9 changed files with 123 additions and 12 deletions
+1 -1
View File
@@ -73,6 +73,6 @@
</dict>
</dict>
<key>MusicBridgeSharedKeychainGroup</key>
<string>$(AppIdentifierPrefix)ru.yukinoki.musicbridge.remote-control</string>
<string>ru.yukinoki.musicbridge.remote-control</string>
</dict>
</plist>
+9 -1
View File
@@ -44,21 +44,29 @@ final class SystemPlayerManager: ObservableObject {
func restore(connection: Connection?) async {
guard #available(iOS 27.0, *), id == nil, !busy,
let savedID = UserDefaults.standard.string(forKey: savedIDKey) else { return }
busy = true
id = savedID
let operation = generation
defer { if generation == operation { busy = false } }
do {
let saved = try SystemPlayerCredentials.load(savedID)
guard let connection, saved.fingerprint == connection.fingerprint, saved.token == connection.token else {
try SystemPlayerCredentials.delete(savedID)
UserDefaults.standard.removeObject(forKey: savedIDKey)
for session in try await RemoteMediaSession<SystemPlayerAttributes>.sessions() where session.id == savedID { try await session.end() }
if generation == operation { id = nil }
return
}
if let session = try await RemoteMediaSession<SystemPlayerAttributes>.sessions().first(where: { $0.id == savedID }) {
guard generation == operation else { return }
storage = session; id = savedID; running = true
} else {
guard generation == operation else { return }
try SystemPlayerCredentials.delete(savedID)
UserDefaults.standard.removeObject(forKey: savedIDKey)
id = nil
}
} catch { self.error = BridgeError.describe(error) }
} catch { if generation == operation { self.error = BridgeError.describe(error); id = nil } }
}
func receive(_ state: MediaState, connection: Connection) {