Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

MediaSession.Builder

public static final class MediaSession.Builder
extends Object

java.lang.Object
   ↳ 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

Builder(Context context, SessionPlayer player)

Public methods

MediaSession build()

Builds a MediaSession.

MediaSession.Builder setExtras(Bundle extras)

Sets extras for the session token.

MediaSession.Builder setId(String id)

Sets the ID of the session.

MediaSession.Builder setSessionActivity(PendingIntent pi)

Sets an intent for launching UI for this Session.

MediaSession.Builder setSessionCallback(Executor executor, MediaSession.SessionCallback callback)

Sets callback for the session.

Inherited methods

Public constructors

Builder

public Builder (Context context, 
                SessionPlayer player)

Parameters
context Context

player SessionPlayer

Public methods

build

public MediaSession build ()

Builds a MediaSession.

Returns
MediaSession a new session

setExtras

public MediaSession.Builder setExtras (Bundle extras)

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

Parameters
extras Bundle

Returns
MediaSession.Builder the Builder to allow chaining

setId

public MediaSession.Builder setId (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 String: id of the session. Must be unique per package.

Returns
MediaSession.Builder

setSessionActivity

public MediaSession.Builder 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 Context.startActivity(Intent).

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

Returns
MediaSession.Builder

setSessionCallback

public MediaSession.Builder setSessionCallback (Executor executor, 
                MediaSession.SessionCallback callback)

Sets callback for the session.

Parameters
executor Executor: callback executor

callback MediaSession.SessionCallback: session callback

Returns
MediaSession.Builder