RemoteSessionPlayer

abstract class RemoteSessionPlayer : SessionPlayer
kotlin.Any
   ↳ 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

open

A callback class to receive notifications for events on the remote session player.

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 adjustVolume(int).

Inherited constants

Public constructors

Base interface for all remote media players that want media session and playback happens on the remote device through MediaRouter.

Public methods

abstract Future<SessionPlayer.PlayerResult!>
adjustVolume(direction: Int)

Adjust player volume with the direction.

abstract Int

Gets the maximum volume that can be used in setVolume(int).

abstract Int

Gets the current volume of this player to this player.

abstract Int

Gets the volume type.

abstract Future<SessionPlayer.PlayerResult!>
setVolume(volume: Int)

Sets the volume of the audio of the media to play, expressed as a linear multiplier on the audio samples.

Inherited functions

Constants

VOLUME_CONTROL_ABSOLUTE

static val VOLUME_CONTROL_ABSOLUTE: Int

The volume control uses an absolute value. It may be adjusted using adjustVolume(int) or set directly using setVolume(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 adjustVolume(int). Attempts to set the volume to a specific value should be ignored.

Value: 1

Public constructors

<init>

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.

Public methods

adjustVolume

@NonNull abstract fun adjustVolume(direction: Int): Future<SessionPlayer.PlayerResult!>

Adjust 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.
Return
Future<SessionPlayer.PlayerResult!>: result of adjusting the volume. Shouldn't be null.

getMaxVolume

abstract fun getMaxVolume(): Int

Gets the maximum volume that can be used in setVolume(int).

Return
Int: the maximum volume. Shouldn't be negative.

getVolume

abstract fun getVolume(): Int

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.

Return
Int: the player volume.

getVolumeControlType

abstract fun getVolumeControlType(): Int

Gets the volume type.

This shouldn't be changed after instantiation.

Return
Int: one of the volume type

setVolume

@NonNull abstract fun setVolume(volume: Int): Future<SessionPlayer.PlayerResult!>

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().
Return
Future<SessionPlayer.PlayerResult!>: result of setting the volume. Shouldn't be null.