Google is committed to advancing racial equity for Black communities. See how.

Builder

class Builder : BuilderBase<MediaBrowser!, MediaBrowser.Builder!, MediaBrowser.BrowserCallback!>
androidx.media2.session.MediaBrowser.Builder

Builder for MediaBrowser.

To set the token of the session for the controller to connect to, one of the setSessionToken(SessionToken) or setSessionCompatToken(MediaSessionCompat.Token) should be called. Otherwise, the build() will throw an IllegalArgumentException.

Any incoming event from the MediaSession will be handled on the callback executor.

Summary

Public constructors
<init>(@NonNull context: Context)

Public methods
MediaBrowser

Builds a MediaBrowser.

MediaBrowser.Builder
setConnectionHints(@NonNull connectionHints: Bundle)

MediaBrowser.Builder
setControllerCallback(@NonNull executor: Executor, @NonNull callback: MediaBrowser.BrowserCallback)

MediaBrowser.Builder

MediaBrowser.Builder
setSessionToken(@NonNull token: SessionToken)

Public constructors

<init>

Builder(@NonNull context: Context)

Public methods

build

@NonNull fun build(): MediaBrowser

Builds a MediaBrowser.

Return
MediaBrowser a new browser
Exceptions
IllegalArgumentException if both SessionToken and MediaSessionCompat.Token are not set.

setConnectionHints

@NonNull fun setConnectionHints(@NonNull connectionHints: Bundle): MediaBrowser.Builder

setControllerCallback

@NonNull fun setControllerCallback(
    @NonNull executor: Executor,
    @NonNull callback: MediaBrowser.BrowserCallback
): MediaBrowser.Builder

setSessionCompatToken

@NonNull fun setSessionCompatToken(@NonNull compatToken: MediaSessionCompat.Token): MediaBrowser.Builder

setSessionToken

@NonNull fun setSessionToken(@NonNull token: SessionToken): MediaBrowser.Builder