mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
feat(media): include airplay for apple music on lock screen widget
This commit is contained in:
parent
75bb8ce9be
commit
5e1e8f613b
3 changed files with 115 additions and 5 deletions
|
|
@ -47,6 +47,8 @@ struct AirPlayDevice: Identifiable, Equatable {
|
|||
|
||||
@MainActor
|
||||
final class AppleMusicAirPlayManager: ObservableObject {
|
||||
static let shared = AppleMusicAirPlayManager()
|
||||
|
||||
@Published private(set) var devices: [AirPlayDevice] = []
|
||||
@Published private(set) var isLoading = false
|
||||
|
||||
|
|
@ -136,6 +138,14 @@ final class AppleMusicAirPlayManager: ObservableObject {
|
|||
|
||||
// MARK: - Volume control
|
||||
|
||||
/// Returns the most recent volume the user set for a device, whether it's
|
||||
/// still pending, already committed, or (as fallback) the last fetched value.
|
||||
func currentVolume(for deviceID: String) -> Int {
|
||||
if let pending = userSetVolume[deviceID] { return pending }
|
||||
if let committed = lastCommittedVolume[deviceID] { return committed }
|
||||
return devices.first { $0.id == deviceID }?.volume ?? 0
|
||||
}
|
||||
|
||||
/// Called by the slider on every drag value change.
|
||||
/// Does NOT mutate any @Published property — this is critical to prevent
|
||||
/// SwiftUI from recreating the slider view and resetting its @State.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue