Register now for Android Dev Summit 2019!

Builder

class Builder : BuilderBase<MediaSession!, MediaSession.Builder!, MediaSession.SessionCallback!>
androidx.media2.session.MediaSession.Builder

Builder for MediaSession.

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

Public constructors

<init>(@NonNull context: Context, @NonNull player: SessionPlayer)

Public methods

MediaSession

MediaSession.Builder
setExtras(@NonNull extras: Bundle)

MediaSession.Builder
setId(@NonNull id: String)

MediaSession.Builder

MediaSession.Builder
setSessionCallback(@NonNull executor: Executor, @NonNull callback: MediaSession.SessionCallback)

Public constructors

<init>

Builder(@NonNull context: Context, @NonNull player: SessionPlayer)

Public methods

build

@NonNull fun build(): MediaSession

setExtras

@NonNull fun setExtras(@NonNull extras: Bundle): MediaSession.Builder

setId

@NonNull fun setId(@NonNull id: String): MediaSession.Builder

setSessionActivity

@NonNull fun setSessionActivity(@Nullable pi: PendingIntent?): MediaSession.Builder

setSessionCallback

@NonNull fun setSessionCallback(@NonNull executor: Executor, @NonNull callback: MediaSession.SessionCallback): MediaSession.Builder