The Android Developer Challenge is back! Submit your idea before December 2.

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

Build 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

Build MediaBrowser.

It will throw an IllegalArgumentException if both SessionToken and MediaSessionCompat.Token are not set.

Return
MediaBrowser: a new browser

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