public final class

MediaLibraryService.MediaLibrarySession.Builder

extends androidx.media2.session.MediaSession.BuilderBase<MediaLibraryService.MediaLibrarySession, MediaLibraryService.MediaLibrarySession.Builder, MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback>

 java.lang.Object

↳androidx.media2.session.MediaSession.BuilderBase<MediaLibraryService.MediaLibrarySession, MediaLibraryService.MediaLibrarySession.Builder, MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback>

↳androidx.media2.session.MediaLibraryService.MediaLibrarySession.Builder

Overview

Builder for MediaLibraryService.MediaLibrarySession.

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

Summary

Constructors
publicBuilder(MediaLibraryService service, SessionPlayer player, java.util.concurrent.Executor callbackExecutor, MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback callback)

Methods
abstract MediaSessionbuild()

Builds a MediaSession.

androidx.media2.session.MediaSession.BuilderBase<T, U, C>setExtras(Bundle extras)

Sets extras for the session token.

androidx.media2.session.MediaSession.BuilderBase<T, U, C>setId(java.lang.String id)

Sets the ID of the session.

androidx.media2.session.MediaSession.BuilderBase<T, U, C>setSessionActivity(PendingIntent pi)

Sets an intent for launching UI for this Session.

public MediaLibraryService.MediaLibrarySession.BuildersetThrowsWhenInvalidReturn(boolean throwsWhenInvalidReturn)

Prevents session to be crashed when it returns any invalid return.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(MediaLibraryService service, SessionPlayer player, java.util.concurrent.Executor callbackExecutor, MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback callback)

Methods

androidx.media2.session.MediaSession.BuilderBase<T, U, C> setSessionActivity(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 .

Parameters:

pi: The intent to launch to show UI for this session.

androidx.media2.session.MediaSession.BuilderBase<T, U, C> setId(java.lang.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:

id: id of the session. Must be unique per package.

Returns:

androidx.media2.session.MediaSession.BuilderBase<T, U, C> setExtras(Bundle extras)

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

Returns:

the Builder to allow chaining

See also: SessionToken.getExtras()

public MediaLibraryService.MediaLibrarySession.Builder setThrowsWhenInvalidReturn(boolean throwsWhenInvalidReturn)

Prevents session to be crashed when it returns any invalid return.

abstract MediaSession build()

Builds a MediaSession.

Returns:

a new session