public final class

MediaSession.Builder

extends androidx.media2.MediaSession.BuilderBase<MediaSession, MediaSession.Builder, MediaSession.SessionCallback>

 java.lang.Object

↳androidx.media2.MediaSession.BuilderBase<MediaSession, MediaSession.Builder, MediaSession.SessionCallback>

↳androidx.media2.MediaSession.Builder

Overview

Builder for MediaSession.

Any incoming event from the MediaController will be handled on the thread that created session with the MediaSession.Builder.build().

Summary

Constructors
publicBuilder(Context context, SessionPlayer player)

Methods
abstract MediaSessionbuild()

Build MediaSession.

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

Set ID of the session.

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

Set an intent for launching UI for this Session.

androidx.media2.MediaSession.BuilderBase<T, U, C>setSessionCallback(java.util.concurrent.Executor executor, MediaSession.SessionCallback callback)

Set callback for the session.

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

Constructors

public Builder(Context context, SessionPlayer player)

Methods

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

Set 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.MediaSession.BuilderBase<T, U, C> setId(java.lang.String id)

Set ID of the session. If it's not set, an empty string with 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.MediaSession.BuilderBase<T, U, C> setSessionCallback(java.util.concurrent.Executor executor, MediaSession.SessionCallback callback)

Set callback for the session.

Parameters:

executor: callback executor
callback: session callback.

Returns:

abstract MediaSession build()

Build MediaSession.

Returns:

a new session