Add playback handoff support
This commit is contained in:
1 parent
c72596ef44
commit
77c00cc47e
5 files changed
+440
-1
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@EnvironmentObject private var player: PlayerManager
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@StateObject private var session: AuthSessionStore
|
||||
private let restoresSession: Bool
|
||||
|
||||
@@ -28,6 +30,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
.task {
|
||||
player.setAuthenticated(session.state == .signedIn)
|
||||
guard restoresSession else { return }
|
||||
#if DEBUG
|
||||
print("[ContentView] session restore task started")
|
||||
@@ -36,6 +39,13 @@ struct ContentView: View {
|
||||
}
|
||||
#endif
|
||||
await session.restoreSession()
|
||||
player.setAuthenticated(session.state == .signedIn)
|
||||
}
|
||||
.onChange(of: session.state) { _, state in
|
||||
player.setAuthenticated(state == .signedIn)
|
||||
}
|
||||
.onChange(of: scenePhase) { _, phase in
|
||||
if phase == .background { player.saveHandoffForBackground() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user