public abstract class VolumeProviderCompat extends Object
MediaSessionCompat.setPlaybackToRemote(android.support.v4.media.VolumeProviderCompat)
.Modifier and Type | Class and Description |
---|---|
static class |
VolumeProviderCompat.Callback
Listens for changes to the volume.
|
static interface |
VolumeProviderCompat.ControlType |
Modifier and Type | Field and Description |
---|---|
static int |
VOLUME_CONTROL_ABSOLUTE
The volume control uses an absolute value.
|
static int |
VOLUME_CONTROL_FIXED
The volume is fixed and can not be modified.
|
static int |
VOLUME_CONTROL_RELATIVE
The volume control uses relative adjustment via
onAdjustVolume(int) . |
Constructor and Description |
---|
VolumeProviderCompat(int volumeControl,
int maxVolume,
int currentVolume)
Create a new volume provider for handling volume events.
|
Modifier and Type | Method and Description |
---|---|
int |
getCurrentVolume()
Get the current volume of the provider.
|
int |
getMaxVolume()
Get the maximum volume this provider allows.
|
int |
getVolumeControl()
Get the volume control type that this volume provider uses.
|
Object |
getVolumeProvider()
Gets the underlying framework
VolumeProvider object. |
void |
onAdjustVolume(int direction)
Override to handle requests to adjust the volume of the current output.
|
void |
onSetVolumeTo(int volume)
Override to handle requests to set the volume of the current output.
|
void |
setCallback(VolumeProviderCompat.Callback callback)
Sets a callback to receive volume changes.
|
void |
setCurrentVolume(int currentVolume)
Set the current volume and notify the system that the volume has been
changed.
|
public static final int VOLUME_CONTROL_FIXED
public static final int VOLUME_CONTROL_RELATIVE
onAdjustVolume(int)
. Attempts to set the volume to a specific
value should be ignored.public static final int VOLUME_CONTROL_ABSOLUTE
onAdjustVolume(int)
or set directly using
onSetVolumeTo(int)
.public VolumeProviderCompat(int volumeControl, int maxVolume, int currentVolume)
volumeControl
- The method for controlling volume that is used by
this provider.maxVolume
- The maximum allowed volume.currentVolume
- The current volume.public final int getCurrentVolume()
public final int getVolumeControl()
public final int getMaxVolume()
public final void setCurrentVolume(int currentVolume)
currentVolume
- The current volume of the output.public void onSetVolumeTo(int volume)
volume
- The volume to set the output to.public void onAdjustVolume(int direction)
direction
- The direction to adjust the volume in.public void setCallback(VolumeProviderCompat.Callback callback)
Used internally by the support library.
public Object getVolumeProvider()
VolumeProvider
object.
This method is only supported on API 21+.
VolumeProvider
object, or null if none.