volumeChanged(for:)
Notifies the system that the volume state has changed on a remote device.
Declaration
@MainActor final func volumeChanged(for device: MediaOutputDevice)Parameters
- device:
The device whose volume state has changed.
Mentioned in
Discussion
Call this function when the remote device’s volume level or mute state changes independently of system-initiated volume control calls. This is typically needed when:
The device’s physical volume buttons are pressed
The device’s volume is changed through its own interface or remote control
Another application or service modifies the device’s volume
The device automatically adjusts volume (for example, due to content normalization)
After calling this function, the system will query the current volume state by calling the appropriate getter based on the device’s volumeControl:
For MediaOutputDevice.VolumeControl.absolute devices: volume(for:) and/or isDeviceMuted(_:) will be called (if canMute is
true)For MediaOutputDevice.VolumeControl.relative devices: isDeviceMuted(_:) will be called (if canMute is
true)