MediaSession.ConnectionResult.AcceptedResultBuilder


@UnstableApi
public class MediaSession.ConnectionResult.AcceptedResultBuilder


A builder for ConnectionResult instances to accept a connection.

Summary

Public constructors

Creates an instance to configure the result of an accepted connection from a controller.

This method is deprecated.

Use AcceptedResultBuilder instead to start with defaults for the given session and controller, or use AcceptedResultBuilder to initialize the builder with empty commands.

AcceptedResultBuilder(
    MediaSession mediaSession,
    MediaSession.ControllerInfo controllerInfo
)

Creates an instance to configure the result of an accepted connection from a controller with the default available commands given the provided MediaSession and ControllerInfo.

Public methods

MediaSession.ConnectionResult

Returns a new ConnectionResult instance for accepting a connection.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the player commands that are available to the controller that gets this result returned when connecting.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the session commands that are available to the controller that gets this result returned when connecting.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the custom layout, overriding the custom layout of the session.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the media button preferences, overriding the media button preferences of the session.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the session activity, overriding the session activity of the session.

MediaSession.ConnectionResult.AcceptedResultBuilder

Sets the session extras, overriding the extras of the session.

Public constructors

AcceptedResultBuilder

public AcceptedResultBuilder()

Creates an instance to configure the result of an accepted connection from a controller.

The available SessionCommands and Player.Commands default to empty and need to be configured.

AcceptedResultBuilder

public AcceptedResultBuilder(MediaSession mediaSession)

AcceptedResultBuilder

public AcceptedResultBuilder(
    MediaSession mediaSession,
    MediaSession.ControllerInfo controllerInfo
)

Creates an instance to configure the result of an accepted connection from a controller with the default available commands given the provided MediaSession and ControllerInfo.

If the controller is trusted, the DEFAULT_PLAYER_COMMANDS and either DEFAULT_SESSION_COMMANDS or DEFAULT_SESSION_AND_LIBRARY_COMMANDS are set by default (depending on whether the mediaSession is a MediaLibrarySession).

If the controller is not trusted, only DEFAULT_UNTRUSTED_PLAYER_COMMANDS and either DEFAULT_UNTRUSTED_SESSION_COMMANDS or DEFAULT_UNTRUSTED_SESSION_AND_LIBRARY_COMMANDS are set by default.

Parameters
MediaSession mediaSession

The MediaSession for which to create a ConnectionResult.

MediaSession.ControllerInfo controllerInfo

The ControllerInfo for which to create a ConnectionResult.

Public methods

build

public MediaSession.ConnectionResult build()

Returns a new ConnectionResult instance for accepting a connection.

setAvailablePlayerCommands

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setAvailablePlayerCommands(Player.Commands availablePlayerCommands)

Sets the player commands that are available to the controller that gets this result returned when connecting.

This set of available player commands is intersected with the actual player commands supported by a player. The resulting intersection is the set of commands actually being available to a controller.

The default is DEFAULT_PLAYER_COMMANDS.

setAvailableSessionCommands

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setAvailableSessionCommands(SessionCommands availableSessionCommands)

Sets the session commands that are available to the controller that gets this result returned when connecting.

The default is DEFAULT_SESSION_AND_LIBRARY_COMMANDS for a MediaLibrarySession and DEFAULT_SESSION_COMMANDS for a MediaSession.

setCustomLayout

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setCustomLayout(@Nullable List<CommandButton> customLayout)

Sets the custom layout, overriding the custom layout of the session.

This method will be deprecated, prefer to use setMediaButtonPreferences. Note that the media button preferences use slots to define the allowed button placement.

The default is null to indicate that the custom layout of the session should be used.

Make sure to have the session commands of all command buttons of the custom layout included in the available session commands. On the controller side, the enabled flag is set to false if the available commands of the controller do not allow to use a button.

setMediaButtonPreferences

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setMediaButtonPreferences(
    @Nullable List<CommandButton> mediaButtonPreferences
)

Sets the media button preferences, overriding the media button preferences of the session.

The default is null to indicate that the media button preferences of the session should be used.

Make sure to have the session commands of all command buttons of the media button preferences included in the available session commands. On the controller side, the enabled flag is set to false if the available commands of the controller do not allow to use a button.

setSessionActivity

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setSessionActivity(@Nullable PendingIntent sessionActivity)

Sets the session activity, overriding the session activity of the session.

The default is null to indicate that the session activity of the session should be used.

setSessionExtras

@CanIgnoreReturnValue
public MediaSession.ConnectionResult.AcceptedResultBuilder setSessionExtras(Bundle sessionExtras)

Sets the session extras, overriding the extras of the session.

The default is null to indicate that the extras of the session should be used.