Android APIs
public abstract class

RemoteVolumeProvider

extends Object
java.lang.Object
   ↳ android.media.session.RemoteVolumeProvider

Class Overview

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 setPlaybackToRemote(RemoteVolumeProvider).

Summary

Constants
int VOLUME_CONTROL_ABSOLUTE The volume control uses an absolute value.
int VOLUME_CONTROL_FIXED The volume is fixed and can not be modified.
int VOLUME_CONTROL_RELATIVE The volume control uses relative adjustment via onAdjustVolumeBy(int).
Public Constructors
RemoteVolumeProvider(int volumeControl, int maxVolume)
Create a new volume provider for handling volume events.
Public Methods
final int getMaxVolume()
Get the maximum volume this provider allows.
final int getVolumeControl()
Get the volume control type that this volume provider uses.
final void notifyVolumeChanged()
Notify the system that the remote playback's volume has been changed.
void onAdjustVolumeBy(int delta)
Override to handle requests to adjust the volume of the current output.
abstract int onGetCurrentVolume()
Get the current volume of the remote playback.
void onSetVolumeTo(int volume)
Override to handle requests to set the volume of the current output.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int VOLUME_CONTROL_ABSOLUTE

The volume control uses an absolute value. It may be adjusted using onAdjustVolumeBy(int) or set directly using onSetVolumeTo(int).

Constant Value: 2 (0x00000002)

public static final int VOLUME_CONTROL_FIXED

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

Constant Value: 0 (0x00000000)

public static final int VOLUME_CONTROL_RELATIVE

The volume control uses relative adjustment via onAdjustVolumeBy(int). Attempts to set the volume to a specific value should be ignored.

Constant Value: 1 (0x00000001)

Public Constructors

public RemoteVolumeProvider (int volumeControl, int maxVolume)

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 The method for controlling volume that is used by this provider.
maxVolume The maximum allowed volume.

Public Methods

public final int getMaxVolume ()

Get the maximum volume this provider allows.

Returns
  • The max allowed volume.

public final int getVolumeControl ()

Get the volume control type that this volume provider uses.

Returns
  • The volume control type for this volume provider

public final void notifyVolumeChanged ()

Notify the system that the remote playback's volume has been changed.

public void onAdjustVolumeBy (int delta)

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

Parameters
delta The amount to change the volume

public abstract int onGetCurrentVolume ()

Get the current volume of the remote playback.

Returns
  • The current volume.

public void onSetVolumeTo (int volume)

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

Parameters
volume The volume to set the output to.