MediaSessionConnector

class MediaSessionConnector(val mediaSession: MediaSessionCompat)

MediaSessionConnector connects an Android media session to a THEOplayer instance.

// Create and initialize the media session
mediaSession = MediaSessionCompat(this, TAG).apply {
    // Do not let MediaButtons restart the player when the app is not visible
    setMediaButtonReceiver(null)
}

// Create a MediaSessionConnector and attach the THEOplayer instance.
mediaSessionConnector = MediaSessionConnector(mediaSession)
mediaSessionConnector.player = player

// Optionally show debug logs
mediaSessionConnector.debug = true

// Set mediaSession to active
mediaSessionConnector.setActive(true)

See also

Constructors

Link copied to clipboard
constructor(mediaSession: MediaSessionCompat)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether each time update event should trigger an update in playback state.

Link copied to clipboard

The interval the player should skip backward when rewinding, in seconds.

Link copied to clipboard

The interval the player should skip forward when fast-forwarding, in seconds.

Functions

Link copied to clipboard

Add a listener for media session callback actions.

Link copied to clipboard
fun destroy()

Release mediaSession.

Link copied to clipboard

Get metadata for the current media item.

Link copied to clipboard

Get metadata provider for the current media item.

Link copied to clipboard

Force update of the current meta data.

Link copied to clipboard

Force update of current playback state.

Link copied to clipboard

Remove a listener for media session callback actions.

Link copied to clipboard
fun setActive(active: Boolean)

Set mediaSession active flag.

Link copied to clipboard

Pass a custom description for the current media item.