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.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
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 |