MediaLibraryService.MediaLibrarySession.Builder

Added in 1.0.0
Deprecated in 1.3.0

class MediaLibraryService.MediaLibrarySession.Builder


Builder for MediaLibrarySession.

Any incoming event from the MediaController will be handled on the callback executor. If it's not set, getMainExecutor will be used by default.

Summary

Public constructors

Builder(
    service: MediaLibraryService,
    player: SessionPlayer,
    callbackExecutor: Executor,
    callback: MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback
)

Public functions

MediaLibraryService.MediaLibrarySession

Builds a MediaSession.

MediaLibraryService.MediaLibrarySession.Builder
setExtras(extras: Bundle)

Sets extras for the session token.

MediaLibraryService.MediaLibrarySession.Builder

Sets the ID of the session.

MediaLibraryService.MediaLibrarySession.Builder

Sets an intent for launching UI for this Session.

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.3.0
Builder(
    service: MediaLibraryService,
    player: SessionPlayer,
    callbackExecutor: Executor,
    callback: MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback
)

Public functions

build

Added in 1.0.0
Deprecated in 1.3.0
fun build(): MediaLibraryService.MediaLibrarySession

Builds a MediaSession.

Throws
java.lang.IllegalStateException

if the session with the same id already exists for the package.

setExtras

Added in 1.0.0
Deprecated in 1.3.0
fun setExtras(extras: Bundle): MediaLibraryService.MediaLibrarySession.Builder

Sets extras for the session token. If not set, getExtras will return an empty Bundle.

Returns
MediaLibraryService.MediaLibrarySession.Builder

the Builder to allow chaining

Throws
java.lang.IllegalArgumentException

if the bundle contains any non-framework Parcelable objects.

See also
getExtras

setId

Added in 1.0.0
Deprecated in 1.3.0
fun setId(id: String): MediaLibraryService.MediaLibrarySession.Builder

Sets the ID of the session. If it's not set, an empty string will be used to create a session.

Use this if and only if your app supports multiple playback at the same time and also wants to provide external apps to have finer controls of them.

Parameters
id: String

id of the session. Must be unique per package.

setSessionActivity

Added in 1.0.0
Deprecated in 1.3.0
fun setSessionActivity(pi: PendingIntent?): MediaLibraryService.MediaLibrarySession.Builder

Sets an intent for launching UI for this Session. This can be used as a quick link to an ongoing media screen. The intent should be for an activity that may be started using startActivity.

Parameters
pi: PendingIntent?

The intent to launch to show UI for this session.