MediaLibraryService.MediaLibrarySession.Builder

Added in 1.0.0
Deprecated in 1.3.0

public final 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

Public constructors

Builder

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

Public methods

build

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaLibraryService.MediaLibrarySession build()

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
public @NonNull MediaLibraryService.MediaLibrarySession.Builder setExtras(@NonNull Bundle extras)

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

Returns
@NonNull 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
public @NonNull MediaLibraryService.MediaLibrarySession.Builder setId(@NonNull String id)

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
@NonNull String id

id of the session. Must be unique per package.

setSessionActivity

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaLibraryService.MediaLibrarySession.Builder setSessionActivity(@Nullable PendingIntent pi)

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
@Nullable PendingIntent pi

The intent to launch to show UI for this session.