ListenableFuture<SessionResult!> |
addPlaylistItem(@IntRange(0) index: Int, @NonNull mediaId: String)
Requests that the SessionPlayer associated with the connected MediaSession adds the media item to the playlist at the index with the media ID. Index equals to or greater than the current playlist size (e.g. Integer#MAX_VALUE ) will add the item at the end of the playlist.
If index is less than or equal to the current index of the playlist, the current index of the playlist will be increased correspondingly.
On success, a SessionResult would be returned with item added.
|
ListenableFuture<SessionResult!> |
adjustVolume(direction: Int, flags: Int)
Requests that the connected MediaSession adjusts the volume of the output that is playing on. The direction must be one of AudioManager#ADJUST_LOWER , AudioManager#ADJUST_RAISE , or AudioManager#ADJUST_SAME .
The command will be ignored if the session does not support VolumeProviderCompat#VOLUME_CONTROL_RELATIVE or VolumeProviderCompat#VOLUME_CONTROL_ABSOLUTE .
If the session is local playback, this changes the device's volume with the stream that session's player is using. Flags will be specified for the AudioManager .
If the session is remote player (i.e. session has set volume provider), its volume provider will receive this request instead.
|
Unit |
close()
Releases this object, and disconnects from the session. After this, callbacks wouldn't be received.
|
ListenableFuture<SessionResult!> |
deselectTrack(@NonNull trackInfo: SessionPlayer.TrackInfo)
Requests that the SessionPlayer associated with the connected MediaSession deselects the TrackInfo for the current media item.
Generally, a track should already be selected in order to be deselected and audio and video tracks should not be deselected.
The types of tracks supported may vary based on players.
Note: getSelectedTrack(int) returns the currently selected track per track type that can be deselected, but the list may be invalidated when ControllerCallback#onTracksChanged(MediaController, List) is called.
|
ListenableFuture<SessionResult!> |
fastForward()
Requests that the SessionPlayer associated with the connected MediaSession to fast forward playback.
The implementation may be different depending on the players. For example, it can be implemented by seeking forward once, series of seeking forward, or increasing playback speed. If you need full control, then use seekTo or setPlaybackSpeed directly.
|
SessionCommandGroup? |
getAllowedCommands()
Gets the cached allowed commands from ControllerCallback#onAllowedCommandsChanged . If it is not connected yet, it returns null .
|
Long |
getBufferedPosition()
Gets the position for how much has been buffered of the SessionPlayer associated with the connected MediaSession , or SessionPlayer#UNKNOWN_TIME if unknown or not connected.
|
Int |
getBufferingState()
Gets the current buffering state of the SessionPlayer associated with the connected MediaSession .
The position is the relative position based on the MediaItem#getStartPosition() . So the position 0 means the start position of the MediaItem .
|
SessionToken? |
getConnectedToken()
Returns the SessionToken of the connected session. If it is not connected yet, it returns null .
This may differ from the SessionToken from the constructor. For example, if the controller is created with the token for MediaSessionService , this would return token for the MediaSession in the service.
|
MediaItem? |
getCurrentMediaItem()
Gets the current media item of the SessionPlayer associated with the connected MediaSession . This can be currently playing or would be played with later play . This value may be updated when ControllerCallback#onCurrentMediaItemChanged(MediaController, MediaItem) or ControllerCallback#onPlaylistChanged(MediaController, List, MediaMetadata) is called.
|
Int |
getCurrentMediaItemIndex()
Gets the current item index in the playlist of the SessionPlayer associated with the connected MediaSession . The value would be updated when ControllerCallback#onCurrentMediaItemChanged(MediaController, MediaItem) or ControllerCallback#onPlaylistChanged(MediaController, List, MediaMetadata) is called.
|
Long |
getCurrentPosition()
Gets the playback position of the SessionPlayer associated with the connected MediaSession .
The position is the relative position based on the MediaItem#getStartPosition() . So the position 0 means the start position of the MediaItem .
|
Long |
getDuration()
Gets the duration of the current media item, or SessionPlayer#UNKNOWN_TIME if unknown or not connected. If the current MediaItem has either start or end position, then duration would be adjusted accordingly instead of returning the whole size of the MediaItem .
|
Int |
getNextMediaItemIndex()
Gets the next item index in the playlist of the SessionPlayer associated with the connected MediaSession . This value would be updated when ControllerCallback#onCurrentMediaItemChanged(MediaController, MediaItem) or ControllerCallback#onPlaylistChanged(MediaController, List, MediaMetadata) is called.
Interoperability: When connected to android.support.v4.media.session.MediaSessionCompat , this will always return SessionPlayer#INVALID_ITEM_INDEX ..
|
MediaController.PlaybackInfo? |
getPlaybackInfo()
Get the current playback info for this session. If it is not connected yet, it returns null .
|
Float |
getPlaybackSpeed()
Gets the playback speed to be used by the of the SessionPlayer associated with the connected MediaSession when playing. A value of 1.0f is the default playback value, and a negative value indicates reverse playback.
Note that it may differ from the speed set in setPlaybackSpeed(float) .
|
Int |
getPlayerState()
Gets the state of the SessionPlayer associated with the connected MediaSession . If it is not connected yet, it returns SessionPlayer#PLAYER_STATE_IDLE .
|
MutableList<MediaItem!>? |
getPlaylist()
Gets the playlist of the SessionPlayer associated with the connected MediaSession . It can be null if the playlist hasn't been set or it's reset by setMediaItem .
This list may differ from the list that was specified with setPlaylist(List, MediaMetadata) depending on the SessionPlayer implementation.
|