<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaDevice",
  "identifier" : "/documentation/MediaDevice/MediaDeviceExtension/setVolume(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Device"
    ],
    "preciseIdentifier" : "s:11MediaDevice0aB9ExtensionP9setVolume_3forySf_AA0a6OutputB0VtF"
  },
  "title" : "setVolume(_:for:)"
}
-->

# setVolume(_:for:)

Sets the volume level for the specified device.

```
@MainActor func setVolume(_ volume: Float, for device: MediaOutputDevice)
```

## Parameters

`volume`

The volume level to set in the range 0.0 to 1.0.

`device`

The device for which to set the volume.

## Discussion

For a group of devices, individual device volume changes should influence the group volume.

Called when a device supports [`MediaOutputDevice.VolumeControl.absolute`](/documentation/MediaDevice/MediaOutputDevice/VolumeControl-swift.enum/absolute).

## Grouping

For a group of devices, all devices in the group must support [`MediaOutputDevice.VolumeControl.absolute`](/documentation/MediaDevice/MediaOutputDevice/VolumeControl-swift.enum/absolute).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)