---
title: MPVolumeView
framework: mediaplayer
role: symbol
role_heading: Class
path: mediaplayer/mpvolumeview
---

# MPVolumeView

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

## Declaration

```swift
class MPVolumeView
```

## Overview

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 UIView class on a view using Interface Builder, sizing and positioning it as desired to contain the volume view. Point to the 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 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. note: You can’t subclass the MPVolumeView class. Customizing the volume slider’s appearance The volume slider is a 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](mediaplayer/mpvolumeview/showsvolumeslider.md)

### Customizing the volume slider

- [maximumVolumeSliderImage(for:)](mediaplayer/mpvolumeview/maximumvolumesliderimage(for:).md)
- [minimumVolumeSliderImage(for:)](mediaplayer/mpvolumeview/minimumvolumesliderimage(for:).md)
- [setMaximumVolumeSliderImage(_:for:)](mediaplayer/mpvolumeview/setmaximumvolumesliderimage(_:for:).md)
- [setMinimumVolumeSliderImage(_:for:)](mediaplayer/mpvolumeview/setminimumvolumesliderimage(_:for:).md)
- [setVolumeThumbImage(_:for:)](mediaplayer/mpvolumeview/setvolumethumbimage(_:for:).md)
- [volumeSliderRect(forBounds:)](mediaplayer/mpvolumeview/volumesliderrect(forbounds:).md)
- [volumeThumbImage(for:)](mediaplayer/mpvolumeview/volumethumbimage(for:).md)
- [volumeThumbRect(forBounds:volumeSliderRect:value:)](mediaplayer/mpvolumeview/volumethumbrect(forbounds:volumesliderrect:value:).md)

### Deprecated

- [volumeWarningSliderImage](mediaplayer/mpvolumeview/volumewarningsliderimage.md)
- [showsRouteButton](mediaplayer/mpvolumeview/showsroutebutton.md)
- [areWirelessRoutesAvailable](mediaplayer/mpvolumeview/arewirelessroutesavailable.md)
- [isWirelessRouteActive](mediaplayer/mpvolumeview/iswirelessrouteactive.md)
- [routeButtonImage(for:)](mediaplayer/mpvolumeview/routebuttonimage(for:).md)
- [routeButtonRect(forBounds:)](mediaplayer/mpvolumeview/routebuttonrect(forbounds:).md)
- [setRouteButtonImage(_:for:)](mediaplayer/mpvolumeview/setroutebuttonimage(_:for:).md)

## Relationships

### Inherits From

- [UIView](uikit/uiview.md)

### Conforms To

- [CALayerDelegate](quartzcore/calayerdelegate.md)
- [CLBodyIdentifiable](corelocation/clbodyidentifiable.md)
- [CMBodyIdentifiable](coremotion/cmbodyidentifiable.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIAccessibilityIdentification](uikit/uiaccessibilityidentification.md)
- [UIActivityItemsConfigurationProviding](uikit/uiactivityitemsconfigurationproviding.md)
- [UIAppearance](uikit/uiappearance.md)
- [UIAppearanceContainer](uikit/uiappearancecontainer.md)
- [UICoordinateSpace](uikit/uicoordinatespace.md)
- [UIDynamicItem](uikit/uidynamicitem.md)
- [UIFocusEnvironment](uikit/uifocusenvironment.md)
- [UIFocusItem](uikit/uifocusitem.md)
- [UIFocusItemContainer](uikit/uifocusitemcontainer.md)
- [UILargeContentViewerItem](uikit/uilargecontentvieweritem.md)
- [UIPasteConfigurationSupporting](uikit/uipasteconfigurationsupporting.md)
- [UIPopoverPresentationControllerSourceItem](uikit/uipopoverpresentationcontrollersourceitem.md)
- [UIResponderStandardEditActions](uikit/uiresponderstandardeditactions.md)
- [UITraitChangeObservable](uikit/uitraitchangeobservable-67e94.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIUserActivityRestoring](uikit/uiuseractivityrestoring.md)

## See Also

### Media player user interface

- [Displaying a media picker from your app](mediaplayer/displaying-a-media-picker-from-your-app.md)
- [MPMediaPickerController](mediaplayer/mpmediapickercontroller.md)
