RemoteSessionPlayer
public
abstract
class
RemoteSessionPlayer
extends SessionPlayer
java.lang.Object | ||
↳ | androidx.media2.common.SessionPlayer | |
↳ | androidx.media2.session.RemoteSessionPlayer |
Base interface for all remote media players that want media session and playback happens on the remote device through MediaRouter.
If you use this to the MediaSession
, session would dispatch incoming volume change event
to the player instead of changing device stream volume.
Summary
Nested classes | |
---|---|
class |
RemoteSessionPlayer.Callback
A callback class to receive notifications for events on the remote session player. |
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
|
Inherited constants |
---|
Public constructors | |
---|---|
RemoteSessionPlayer()
|
Public methods | |
---|---|
abstract
Future<SessionPlayer.PlayerResult>
|
adjustVolume(int direction)
Adjusts player volume with the direction. |
abstract
int
|
getMaxVolume()
Gets the maximum volume that can be used in |
abstract
int
|
getVolume()
Gets the current volume of this player to this player. |
abstract
int
|
getVolumeControlType()
Gets the volume type. |
abstract
Future<SessionPlayer.PlayerResult>
|
setVolume(int volume)
Sets the volume of the audio of the media to play, expressed as a linear multiplier on the audio samples. |
Inherited methods | |
---|---|
Constants
VOLUME_CONTROL_ABSOLUTE
public static final int VOLUME_CONTROL_ABSOLUTE
The volume control uses an absolute value. It may be adjusted using
adjustVolume(int)
or set directly using
setVolume(int)
.
Constant Value: 2 (0x00000002)
VOLUME_CONTROL_FIXED
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)
VOLUME_CONTROL_RELATIVE
public static final int VOLUME_CONTROL_RELATIVE
The volume control uses relative adjustment via
adjustVolume(int)
. Attempts to set the volume to a specific
value should be ignored.
Constant Value: 1 (0x00000001)
Public constructors
RemoteSessionPlayer
public RemoteSessionPlayer ()
Public methods
adjustVolume
public abstract Future<SessionPlayer.PlayerResult> adjustVolume (int direction)
Adjusts player volume with the direction. Override this API to customize volume change in remote device.
This would be ignored when volume control type is VOLUME_CONTROL_FIXED
.
Parameters | |
---|---|
direction |
int : direction of the volume changes. Positive value for volume up, negative for
volume down. |
Returns | |
---|---|
Future<SessionPlayer.PlayerResult> |
result of adjusting the volume. Shouldn't be null .
|
getMaxVolume
public abstract int getMaxVolume ()
Gets the maximum volume that can be used in setVolume(int)
.
Returns | |
---|---|
int |
the maximum volume. Shouldn't be negative. |
getVolume
public abstract int getVolume ()
Gets the current volume of this player to this player.
Note that it does not take into account the associated stream volume because the playback is happening outside of the phone device.
Returns | |
---|---|
int |
the player volume. |
getVolumeControlType
public abstract int getVolumeControlType ()
Gets the volume type.
This shouldn't be changed after instantiation.
Returns | |
---|---|
int |
one of the volume type |
setVolume
public abstract Future<SessionPlayer.PlayerResult> setVolume (int volume)
Sets the volume of the audio of the media to play, expressed as a linear multiplier on the audio samples.
Note that this volume is specific to the player, and is separate from stream volume used across the platform.
A value of 0
indicates muting. See getMaxVolume()
for the volume range
supported by this player.
Parameters | |
---|---|
volume |
int : a value between 0 and getMaxVolume() . |
Returns | |
---|---|
Future<SessionPlayer.PlayerResult> |
result of setting the volume. Shouldn't be null .
|
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-24 UTC.