<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPVolumeView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPVolumeView"
  },
  "title" : "MPVolumeView"
}
-->

# MPVolumeView

A slider control for setting the system audio output volume, and a button for choosing the audio output route.

```
class MPVolumeView
```

## Overview

Use a volume view to present the user with a slider control for setting the system audio output volume, and a button for choosing the audio output route when the option is available. When first displayed, the slider’s position reflects the current system audio output volume. As the user drags the slider, the changes update the volume view. If the user presses the device volume buttons while sound is playing, the slider moves to reflect the new volume.

If there’s an Apple TV or other AirPlay-enabled device in range, the route button allows the user to choose it. If there’s only one audio output route available, the view doesn’t display the route button. The view also doesn’t display a route button when the app runs in visionOS.

> Important:
> You can’t change the volume or choose a route with this class while testing in the Simulator. These abilities only work on a device.

Use this class by embedding an instance of it in your view hierarchy. The following code snippet assumes you’ve placed an instance of the <doc://com.apple.documentation/documentation/UIKit/UIView> class on a view using Interface Builder, sizing and positioning it as desired to contain the volume view. Point to the <doc://com.apple.documentation/documentation/UIKit/UIView> instance with an outlet variable—named, in the case of this example, `mpVolumeViewParentView`. You’d typically place code like that shown in the following code in your `viewDidLoad` method.

Listing 1. Adding a volume view to your view hierarchy

```swift
parentView.backgroundColor = .clear
let volumeView = MPVolumeView(frame: parentView.bounds)
parentView.addSubview(volumeView)
```

When an audio output route that doesn’t support volume control, such as a car head unit, is active, the system replaces the volume slider with the route name.

To instead display a volume slider as an alert, use the functions described in [Global volume setting methods](/documentation/MediaPlayer/global-volume-setting-methods).

> Note:
> You can’t subclass the MPVolumeView class.

### Customizing the volume slider’s appearance

The volume slider is a <doc://com.apple.documentation/documentation/UIKit/UISlider> object. Sliders are always displayed as horizontal bars and an indicator, or **thumb**, notes the current value of the slider, which the user can move to change the setting.

Slider controls draw the volume slider track using two distinct images, which are customizable. The system draws the region between the thumb and the end of the track associated with the slider’s minimum value using the **minimum volume slider image**. The system region between the thumb and the end of the track associated with the slider’s maximum value using the **maximum volume slider image**. You can assign different images to customize the appearance of the slider for its various states, such as enabled, disabled, and highlighted.

You can also customize the volume thumb image for the slider.

> Note:
> The volume slider control provides a set of default images for both the track and thumb. The system uses the default images if you don’t specify any custom images.

## Topics

### Managing visibility of controls

[`showsVolumeSlider`](/documentation/MediaPlayer/MPVolumeView/showsVolumeSlider)

A Boolean value that indicates the volume slider is visible in the volume view.

### Customizing the volume slider

[`maximumVolumeSliderImage(for:)`](/documentation/MediaPlayer/MPVolumeView/maximumVolumeSliderImage(for:))

Returns the maximum volume image associated with the specified control state.

[`minimumVolumeSliderImage(for:)`](/documentation/MediaPlayer/MPVolumeView/minimumVolumeSliderImage(for:))

Returns the minimum volume image associated with the specified control state.

[`setMaximumVolumeSliderImage(_:for:)`](/documentation/MediaPlayer/MPVolumeView/setMaximumVolumeSliderImage(_:for:))

Assigns a maximum volume slider image to the specified control states.

[`setMinimumVolumeSliderImage(_:for:)`](/documentation/MediaPlayer/MPVolumeView/setMinimumVolumeSliderImage(_:for:))

Assigns a minimum volume slider image to the specified control states.

[`setVolumeThumbImage(_:for:)`](/documentation/MediaPlayer/MPVolumeView/setVolumeThumbImage(_:for:))

Assigns a thumb image to the specified control states.

[`volumeSliderRect(forBounds:)`](/documentation/MediaPlayer/MPVolumeView/volumeSliderRect(forBounds:))

Returns the drawing rectangle for the slider’s track.

[`volumeThumbImage(for:)`](/documentation/MediaPlayer/MPVolumeView/volumeThumbImage(for:))

Returns the thumb image associated with the specified control state.

[`volumeThumbRect(forBounds:volumeSliderRect:value:)`](/documentation/MediaPlayer/MPVolumeView/volumeThumbRect(forBounds:volumeSliderRect:value:))

Returns the drawing rectangle for the volume slider’s thumb image.

### Deprecated

[`volumeWarningSliderImage`](/documentation/MediaPlayer/MPVolumeView/volumeWarningSliderImage)

The image used to designate the European Union volume limit.

[`showsRouteButton`](/documentation/MediaPlayer/MPVolumeView/showsRouteButton)

A Boolean value that indicates whether the route button is visible in the volume view.

[`areWirelessRoutesAvailable`](/documentation/MediaPlayer/MPVolumeView/areWirelessRoutesAvailable)

A Boolean value indicating wireless routes are available.

[`isWirelessRouteActive`](/documentation/MediaPlayer/MPVolumeView/isWirelessRouteActive)

A Boolean value that indicates whether the wireless route is active.

[`routeButtonImage(for:)`](/documentation/MediaPlayer/MPVolumeView/routeButtonImage(for:))

Returns the button image associated with the specified control state.

[`routeButtonRect(forBounds:)`](/documentation/MediaPlayer/MPVolumeView/routeButtonRect(forBounds:))

Returns the drawing rectangle for the route button.

[`setRouteButtonImage(_:for:)`](/documentation/MediaPlayer/MPVolumeView/setRouteButtonImage(_:for:))

Assigns a button image to the specified control states.



---

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)