MediaControllerGlue

Added in 1.1.0
Deprecated in 1.1.0

abstract class MediaControllerGlue : PlaybackControlGlue


A helper class for implementing a glue layer for MediaControllerCompat.

Summary

Public constructors

MediaControllerGlue(
    context: Context!,
    fastForwardSpeeds: IntArray!,
    rewindSpeeds: IntArray!
)

Constructor for the glue.

Public functions

Unit

Attaches to the given media controller.

Unit

Detaches from the media controller.

Int

Returns the current position of the media item in milliseconds.

Int

Returns the current playback speed.

Drawable!

Returns a bitmap of the art for the media item.

MediaControllerCompat!

Returns the media controller currently attached.

Int

Returns the duration of the media item in milliseconds.

CharSequence!

Returns the subtitle of the media item.

CharSequence!

Returns the title of the media item.

Long

Returns a bitmask of actions supported by the media player.

Boolean

Returns true if there is a valid media item.

Boolean

Returns true if media is currently playing.

Unit

Goes to the next media item.

Unit

Pauses the media player.

Unit
play(speed: Int)

Start playback at the given speed.

Unit

Goes to the previous media item.

Inherited Constants

From androidx.leanback.media.PlaybackControlGlue
const Int

The adapter key for the first custom control on the left side of the predefined primary controls.

const Int

The adapter key for the first custom control on the right side of the predefined primary controls.

const Int

The adapter key for the fast forward control.

const Int

The adapter key for the play/pause control.

const Int

The adapter key for the rewind control.

const Int

The adapter key for the skip to next control.

const Int

The adapter key for the skip to previous control.

const Int

The initial (level 0) fast forward playback speed.

const Int

The level 1 fast forward playback speed.

const Int

The level 2 fast forward playback speed.

const Int

The level 3 fast forward playback speed.

const Int

The level 4 fast forward playback speed.

const Int

Invalid playback speed.

const Int

Speed representing playback state that is playing normally.

const Int

Speed representing playback state that is paused.

Inherited functions

From androidx.leanback.widget.OnActionClickedListener
abstract Unit

Callback fired when the host fragment receives an action.

From androidx.leanback.media.PlaybackControlGlue
Unit

Override this to start/stop a runnable to call updateProgress at an interval such as getUpdatePeriod.

PlaybackControlsRow!

Returns the playback controls row managed by the glue layer.

PlaybackControlsRowPresenter!

This function is deprecated.

PlaybackControlGlue supports any PlaybackRowPresenter, use getPlaybackRowPresenter.

IntArray<Int>!

Returns the fast forward speeds.

PlaybackRowPresenter!

Returns the playback row Presenter to be passed to PlaybackGlueHost in onAttachedToHost.

IntArray<Int>!

Returns the rewind speeds.

Int

Returns the time period in milliseconds that should be used to update the progress.

Boolean

Returns true if controls are set to fade when media is playing.

Boolean

Returns true if media is currently playing.

Unit

Handles action clicks.

Unit

This method is called attached to associated PlaybackGlueHost.

Unit

Instantiating a PlaybackControlsRow and corresponding PlaybackControlsRowPresenter.

Unit

May be overridden to add primary actions to the adapter.

Unit
onCreateSecondaryActions(secondaryActionsAdapter: ArrayObjectAdapter!)

May be overridden to add secondary actions to the adapter.

Unit

This method is called when current associated PlaybackGlueHost is attached to a different PlaybackGlue or PlaybackGlueHost is destroyed .

Unit

This method is called when PlaybackGlueHost is started.

Unit

This method is called when PlaybackGlueHost is stopped.

Boolean
onKey(v: View!, keyCode: Int, event: KeyEvent!)

Handles key events and returns true if handled.

Unit

Must be called appropriately by a subclass when the metadata state has changed.

Unit

Must be called appropriately by a subclass when the playback state has changed.

Unit

Starts the media player.

Unit

Sets the controls row to be managed by the glue layer.

Unit

This function is deprecated.

PlaybackControlGlue supports any PlaybackRowPresenter, use setPlaybackRowPresenter.

Unit

Sets the controls to fade after a timeout when media is playing.

Unit

Sets the controls row Presenter to be passed to PlaybackGlueHost in onAttachedToHost.

Unit

Updates the progress bar based on the current media playback position.

From androidx.leanback.media.PlaybackGlue
Unit

Add a PlayerCallback.

Context

Returns the context.

PlaybackGlueHost?
(Mutable)List<PlaybackGlue.PlayerCallback!>?
Boolean

Returns true when the media player is prepared to start media playback.

Unit

This method is called when PlaybackGlueHost is paused.

Unit

This method is called when PlaybackGlueHost is resumed.

Unit

Starts play when isPrepared becomes true.

Unit

Remove a PlayerCallback.

Unit

This method is used to associate a PlaybackGlue with the PlaybackGlueHost which provides UI and optional SurfaceHolderGlueHost.

From android.view.View.OnKeyListener
abstract Boolean
onKey(p: View!, p1: Int, p2: KeyEvent!)

Public constructors

MediaControllerGlue

Added in 1.1.0
Deprecated in 1.1.0
MediaControllerGlue(
    context: Context!,
    fastForwardSpeeds: IntArray!,
    rewindSpeeds: IntArray!
)

Constructor for the glue.

Parameters
context: Context!
fastForwardSpeeds: IntArray!

Array of seek speeds for fast forward.

rewindSpeeds: IntArray!

Array of seek speeds for rewind.

Public functions

attachToMediaController

Added in 1.1.0
Deprecated in 1.1.0
fun attachToMediaController(mediaController: MediaControllerCompat!): Unit

Attaches to the given media controller.

detach

Added in 1.1.0
Deprecated in 1.1.0
fun detach(): Unit

Detaches from the media controller. Must be called when the object is no longer needed.

getCurrentPosition

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getCurrentPosition(): Int

Returns the current position of the media item in milliseconds.

getCurrentSpeedId

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getCurrentSpeedId(): Int

Returns the current playback speed. When playing normally, PLAYBACK_SPEED_NORMAL should be returned.

getMediaArt

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getMediaArt(): Drawable!

Returns a bitmap of the art for the media item.

getMediaController

Added in 1.1.0
Deprecated in 1.1.0
fun getMediaController(): MediaControllerCompat!

Returns the media controller currently attached.

getMediaDuration

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getMediaDuration(): Int

Returns the duration of the media item in milliseconds.

getMediaSubtitle

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getMediaSubtitle(): CharSequence!

Returns the subtitle of the media item.

getMediaTitle

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getMediaTitle(): CharSequence!

Returns the title of the media item.

getSupportedActions

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun getSupportedActions(): Long

Returns a bitmask of actions supported by the media player.

hasValidMedia

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun hasValidMedia(): Boolean

Returns true if there is a valid media item.

isMediaPlaying

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
fun isMediaPlaying(): Boolean

Returns true if media is currently playing.

next

fun next(): Unit

Goes to the next media item. This method is optional.

pause

fun pause(): Unit

Pauses the media player.

play

fun play(speed: Int): Unit

Start playback at the given speed.

Parameters
speed: Int

The desired playback speed. For normal playback this will be PLAYBACK_SPEED_NORMAL; higher positive values for fast forward, and negative values for rewind.

previous

fun previous(): Unit

Goes to the previous media item. This method is optional.