# VolumeProviderCompat

Artifact: [androidx.media:media](https://developer.android.com/jetpack/androidx/releases/media) [View Source](https://cs.android.com/search?q=file:androidx/media/VolumeProviderCompat.java+class:androidx.media.VolumeProviderCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

*** ** * ** ***


```
abstract class VolumeProviderCompat
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> androidx.media is deprecated. Please migrate to [androidx.media3](https://developer.android.com/media/media3).

Handles requests to adjust or set the volume on a session. This is also used to push volume updates back to the session after a request has been handled. You can set a volume provider on a session by calling `https://developer.android.com/reference/kotlin/android/support/v4/media/session/MediaSessionCompat#setPlaybackToRemote(androidx.media.VolumeProviderCompat)`.

## Summary

| ### Nested types |
|---|
| `abstract class https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat.Callback` **This class is deprecated.** Deprecated in Java |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#VOLUME_CONTROL_ABSOLUTE() = 2` **This property is deprecated.** Deprecated in Java |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#VOLUME_CONTROL_FIXED() = 0` **This property is deprecated.** Deprecated in Java |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#VOLUME_CONTROL_RELATIVE() = 1` **This property is deprecated.** Deprecated in Java |

| ### Public constructors |
|---|
| `[VolumeProviderCompat](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#VolumeProviderCompat(int,int,int))( volumeControl: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, currentVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getCurrentVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getCurrentVolume())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getMaxVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getMaxVolume())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getVolumeControl](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getVolumeControl())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `[getVolumeProvider](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getVolumeProvider())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onAdjustVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onAdjustVolume(int))(direction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[onSetVolumeTo](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onSetVolumeTo(int))(volume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setCallback](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#setCallback(androidx.media.VolumeProviderCompat.Callback))(callback: https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat.Callback!)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setCurrentVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#setCurrentVolume(int))(currentVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Deprecated in Java |

## Constants

### VOLUME_CONTROL_ABSOLUTE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
const val VOLUME_CONTROL_ABSOLUTE = 2: Int
```

> [!CAUTION]
> **This property is deprecated.**   
> Deprecated in Java

The volume control uses an absolute value. It may be adjusted using `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onAdjustVolume(int)` or set directly using `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onSetVolumeTo(int)`.

### VOLUME_CONTROL_FIXED

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
const val VOLUME_CONTROL_FIXED = 0: Int
```

> [!CAUTION]
> **This property is deprecated.**   
> Deprecated in Java

The volume is fixed and can not be modified. Requests to change volume should be ignored.

### VOLUME_CONTROL_RELATIVE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
const val VOLUME_CONTROL_RELATIVE = 1: Int
```

> [!CAUTION]
> **This property is deprecated.**   
> Deprecated in Java

The volume control uses relative adjustment via `https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onAdjustVolume(int)`. Attempts to set the volume to a specific value should be ignored.

## Public constructors

### VolumeProviderCompat

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
[VolumeProviderCompat](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#VolumeProviderCompat(int,int,int))(
    volumeControl: Int,
    maxVolume: Int,
    currentVolume: Int
)
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Create a new volume provider for handling volume events. You must specify the type of volume control and the maximum volume that can be used.

| Parameters |
|---|---|
| `volumeControl: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The method for controlling volume that is used by this provider. |
| `maxVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum allowed volume. |
| `currentVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The current volume. |

## Public functions

### getCurrentVolume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getCurrentVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getCurrentVolume())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Get the current volume of the provider.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The current volume. |

### getMaxVolume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getMaxVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getMaxVolume())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Get the maximum volume this provider allows.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The max allowed volume. |

### getVolumeControl

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getVolumeControl](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getVolumeControl())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Get the volume control type that this volume provider uses.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The volume control type for this volume provider |

### getVolumeProvider

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getVolumeProvider](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#getVolumeProvider())(): Any!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the underlying framework `https://developer.android.com/reference/android/media/VolumeProvider.html` object.

This method is only supported on API 21+.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | An equivalent `https://developer.android.com/reference/android/media/VolumeProvider.html` object, or null if none. |

### onAdjustVolume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [onAdjustVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onAdjustVolume(int))(direction: Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Override to handle requests to adjust the volume of the current output.

| Parameters |
|---|---|
| `direction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The direction to adjust the volume in. |

### onSetVolumeTo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [onSetVolumeTo](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#onSetVolumeTo(int))(volume: Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Override to handle requests to set the volume of the current output.

| Parameters |
|---|---|
| `volume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The volume to set the output to. |

### setCallback

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [setCallback](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#setCallback(androidx.media.VolumeProviderCompat.Callback))(callback: VolumeProviderCompat.Callback!): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets a callback to receive volume changes.

Used internally by the support library.

### setCurrentVolume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [setCurrentVolume](https://developer.android.com/reference/kotlin/androidx/media/VolumeProviderCompat#setCurrentVolume(int))(currentVolume: Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Set the current volume and notify the system that the volume has been changed.

| Parameters |
|---|---|
| `currentVolume: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The current volume of the output. |