---
title: "setVolume(_:for:)"
framework: mediadevice
role: symbol
role_heading: Instance Method
path: "mediadevice/mediadeviceextension/setvolume(_:for:)"
---

# setVolume(_:for:)

Sets the volume level for the specified device.

## Declaration

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

## Parameters

- `volume`: The volume level to set, typically in the range 0.0 to 1.0.
- `device`: The device for which to set the volume.

## Mentioned in

Creating a media device extension

## Discussion

Discussion For a group of devices, individual device volume changes should influence the group volume. Called when a device supports MediaOutputDevice.VolumeControl.absolute. Grouping For a group of devices, all devices in the group must support MediaOutputDevice.VolumeControl.absolute.
