VolumeProviderCompat
abstract class VolumeProviderCompat
kotlin.Any | |
↳ | androidx.media.VolumeProviderCompat |
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 MediaSessionCompat#setPlaybackToRemote
.
Summary
Nested classes | |
---|---|
abstract |
Listens for changes to the volume. |
Constants | |
---|---|
static Int |
The volume control uses an absolute value. |
static Int |
The volume is fixed and can not be modified. |
static Int |
The volume control uses relative adjustment via |
Public constructors | |
---|---|
Create a new volume provider for handling volume events. |
Public methods | |
---|---|
Int |
Get the current volume of the provider. |
Int |
Get the maximum volume this provider allows. |
Int |
Get the volume control type that this volume provider uses. |
open Any! |
Gets the underlying framework |
open Unit |
onAdjustVolume(direction: Int) Override to handle requests to adjust the volume of the current output. |
open Unit |
onSetVolumeTo(volume: Int) Override to handle requests to set the volume of the current output. |
open Unit |
setCallback(callback: VolumeProviderCompat.Callback!) Sets a callback to receive volume changes. |
Unit |
setCurrentVolume(currentVolume: Int) Set the current volume and notify the system that the volume has been changed. |
Constants
VOLUME_CONTROL_ABSOLUTE
static val VOLUME_CONTROL_ABSOLUTE: Int
The volume control uses an absolute value. It may be adjusted using onAdjustVolume(int)
or set directly using onSetVolumeTo(int)
.
Value: 2
VOLUME_CONTROL_FIXED
static val VOLUME_CONTROL_FIXED: Int
The volume is fixed and can not be modified. Requests to change volume should be ignored.
Value: 0
VOLUME_CONTROL_RELATIVE
static val VOLUME_CONTROL_RELATIVE: Int
The volume control uses relative adjustment via onAdjustVolume(int)
. Attempts to set the volume to a specific value should be ignored.
Value: 1
Public constructors
<init>
VolumeProviderCompat(
volumeControl: Int,
maxVolume: Int,
currentVolume: Int)
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 |
Int: The method for controlling volume that is used by this provider. |
maxVolume |
Int: The maximum allowed volume. |
currentVolume |
Int: The current volume. |
Public methods
getCurrentVolume
fun getCurrentVolume(): Int
Get the current volume of the provider.
Return | |
---|---|
Int |
The current volume. |
getMaxVolume
fun getMaxVolume(): Int
Get the maximum volume this provider allows.
Return | |
---|---|
Int |
The max allowed volume. |
getVolumeControl
fun getVolumeControl(): Int
Get the volume control type that this volume provider uses.
Return | |
---|---|
Int |
The volume control type for this volume provider |
getVolumeProvider
open fun getVolumeProvider(): Any!
Gets the underlying framework android.media.VolumeProvider
object.
This method is only supported on API 21+.
Return | |
---|---|
Any! |
An equivalent android.media.VolumeProvider object, or null if none. |
onAdjustVolume
open fun onAdjustVolume(direction: Int): Unit
Override to handle requests to adjust the volume of the current output.
Parameters | |
---|---|
direction |
Int: The direction to adjust the volume in. |
onSetVolumeTo
open fun onSetVolumeTo(volume: Int): Unit
Override to handle requests to set the volume of the current output.
Parameters | |
---|---|
volume |
Int: The volume to set the output to. |
setCallback
open fun setCallback(