belongs to Maven artifact androidx.media2:media2:1.0.0-alpha01

MediaLibraryService2.MediaLibrarySession.Builder

public static final class MediaLibraryService2.MediaLibrarySession.Builder
extends Object

java.lang.Object
   ↳ androidx.media2.MediaLibraryService2.MediaLibrarySession.Builder


Builder for MediaLibraryService2.MediaLibrarySession.

Summary

Public constructors

MediaLibraryService2.MediaLibrarySession.Builder(MediaLibraryService2 service, Executor callbackExecutor, MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback callback)

Public methods

MediaLibraryService2.MediaLibrarySession build()

Build MediaSession2.

MediaLibraryService2.MediaLibrarySession.Builder setId(String id)

Set ID of the session.

MediaLibraryService2.MediaLibrarySession.Builder setPlayer(BaseMediaPlayer player)

Sets the underlying BaseMediaPlayer for this session to dispatch incoming event to.

MediaLibraryService2.MediaLibrarySession.Builder setPlaylistAgent(MediaPlaylistAgent playlistAgent)

Sets the MediaPlaylistAgent for this session to manages playlist of the underlying BaseMediaPlayer.

MediaLibraryService2.MediaLibrarySession.Builder setSessionActivity(PendingIntent pi)

Set an intent for launching UI for this Session.

Inherited methods

Public constructors

MediaLibraryService2.MediaLibrarySession.Builder

public MediaLibraryService2.MediaLibrarySession.Builder (MediaLibraryService2 service, 
                Executor callbackExecutor, 
                MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback callback)

Parameters
service MediaLibraryService2

callbackExecutor Executor

callback MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback

Public methods

setId

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

Returns
MediaLibraryService2.MediaLibrarySession.Builder

setPlayer

public MediaLibraryService2.MediaLibrarySession.Builder setPlayer (BaseMediaPlayer player)

Sets the underlying BaseMediaPlayer for this session to dispatch incoming event to.

Parameters
player BaseMediaPlayer: a BaseMediaPlayer that handles actual media playback in your app.

Returns
MediaLibraryService2.MediaLibrarySession.Builder

setPlaylistAgent

public MediaLibraryService2.MediaLibrarySession.Builder setPlaylistAgent (MediaPlaylistAgent playlistAgent)

Sets the MediaPlaylistAgent for this session to manages playlist of the underlying BaseMediaPlayer. The playlist agent should manage BaseMediaPlayer for calling BaseMediaPlayer.setNextDataSources(List).

If the MediaPlaylistAgent isn't set, session will create the default playlist agent.

Parameters
playlistAgent MediaPlaylistAgent: a MediaPlaylistAgent that manages playlist of the player

Returns
MediaLibraryService2.MediaLibrarySession.Builder

setSessionActivity

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

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

Returns
MediaLibraryService2.MediaLibrarySession.Builder