belongs to Maven artifact androidx.media:media:1.0.0-alpha1

MediaLibraryService2.MediaLibrarySession.Builder

public static final class MediaLibraryService2.MediaLibrarySession.Builder
extends Object

java.lang.Object
   ↳ androidx.media.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(MediaPlayerInterface player)

Sets the underlying MediaPlayerInterface 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 MediaPlayerInterface.

MediaLibraryService2.MediaLibrarySession.Builder setSessionActivity(PendingIntent pi)

Set an intent for launching UI for this Session.

MediaLibraryService2.MediaLibrarySession.Builder setVolumeProvider(VolumeProviderCompat volumeProvider)

Sets the VolumeProviderCompat for this session to handle volume events.

Inherited methods

Public constructors

MediaLibraryService2.MediaLibrarySession.Builder

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

Parameters
service MediaLibraryService2

callbackExecutor Executor

callback MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback

Public methods

setId

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

MediaLibraryService2.MediaLibrarySession.Builder setPlayer (MediaPlayerInterface player)

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

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

Returns
MediaLibraryService2.MediaLibrarySession.Builder

setPlaylistAgent

MediaLibraryService2.MediaLibrarySession.Builder setPlaylistAgent (MediaPlaylistAgent playlistAgent)

Sets the MediaPlaylistAgent for this session to manages playlist of the underlying MediaPlayerInterface. The playlist agent should manage MediaPlayerInterface for calling MediaPlayerInterface.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

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

setVolumeProvider

MediaLibraryService2.MediaLibrarySession.Builder setVolumeProvider (VolumeProviderCompat volumeProvider)

Sets the VolumeProviderCompat for this session to handle volume events. If not set, system will adjust the appropriate stream volume for this session's player.

Parameters
volumeProvider VolumeProviderCompat: The provider that will receive volume button events.

Returns
MediaLibraryService2.MediaLibrarySession.Builder