Package com.castlabs.sdk.mediasession

# Class MediaSessionBuilder

java.lang.Object
com.castlabs.sdk.mediasession.MediaSessionBuilder

public final class MediaSessionBuilder extends Object
Media Session builder allowing customizations

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `MediaSessionBuilder.Listener`
  A listener to provide media session events.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MediaSessionBuilder()`
  Constructs default MediaSessionBuilder

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MediaSessionBuilder`
  `setCommandButtons(ArrayList<androidx.media3.session.CommandButton> commandButtons)`
  Sets custom command buttons that will be shown in the media style notification.
  `MediaSessionBuilder`
  `setCustomMediaSessionServiceClass(Class<? extends androidx.media3.session.MediaSessionService> customMediaSessionServiceClass)`
  Sets a custom media session service class.
  `MediaSessionBuilder`
  `setFastForwardIncrementMs(int fastForwardMs)`
  Sets the fast forward increment in milliseconds
  `MediaSessionBuilder`
  `setListener(MediaSessionBuilder.Listener listener)`
  Sets a listener for receiving media session events.
  `MediaSessionBuilder`
  `setPlayerCommands(androidx.media3.common.Player.Commands playerCommands)`
  Sets available player commands for the session.
  `MediaSessionBuilder`
  `setRewindIncrementMs(int rewindMs)`
  Sets the rewind increment in milliseconds
  `MediaSessionBuilder`
  `setSessionActivity(PendingIntent pendingIntent)`
  Sets a `PendingIntent` to launch an `Activity` for the `MediaSession`.
  `MediaSessionBuilder`
  `setSessionCommands(androidx.media3.session.SessionCommands sessionCommands)`
  Sets custom session commands for the session.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MediaSessionBuilder

    public MediaSessionBuilder()
    Constructs default MediaSessionBuilder

- ## Method Details

  - ### setRewindIncrementMs

    @NonNull public MediaSessionBuilder setRewindIncrementMs(int rewindMs)
    Sets the rewind increment in milliseconds
    Parameters:
      `rewindMs` - The rewind increment in milliseconds. A non-positive value will cause the rewind to be disabled
    Returns:
      This builder

  - ### setFastForwardIncrementMs

    @NonNull public MediaSessionBuilder setFastForwardIncrementMs(int fastForwardMs)
    Sets the fast forward increment in milliseconds
    Parameters:
      `fastForwardMs` - The fast forward increment in milliseconds. A non-positive value will cause the fast forward to be disabled
    Returns:
      This builder

  - ### setSessionCommands

    @NonNull public MediaSessionBuilder setSessionCommands(@NonNull androidx.media3.session.SessionCommands sessionCommands)
    Sets custom session commands for the session.
    Parameters:
      `sessionCommands` - The session commands to be set
    Returns:
      This builder

  - ### setPlayerCommands

    @NonNull public MediaSessionBuilder setPlayerCommands(@NonNull androidx.media3.common.Player.Commands playerCommands)
    Sets available player commands for the session.
    Parameters:
      `playerCommands` - The player commands to be set
    Returns:
      This builder

  - ### setCommandButtons

    @NonNull public MediaSessionBuilder setCommandButtons(@NonNull ArrayList<androidx.media3.session.CommandButton> commandButtons)
    Sets custom command buttons that will be shown in the media style notification.
    Parameters:
      `commandButtons` - The command buttons to be set
    Returns:
      This builder

  - ### setListener

    @NonNull public MediaSessionBuilder setListener(@Nullable MediaSessionBuilder.Listener listener)
    Sets a listener for receiving media session events.
    Parameters:
      `listener` - The listener to be set
    Returns:
      This builder

  - ### setCustomMediaSessionServiceClass

    @NonNull public MediaSessionBuilder setCustomMediaSessionServiceClass(@Nullable Class<? extends androidx.media3.session.MediaSessionService> customMediaSessionServiceClass)
    Sets a custom media session service class.
    Parameters:
      `customMediaSessionServiceClass` - The custom media session service class to be set
    Returns:
      This builder

  - ### setSessionActivity

    @NonNull public MediaSessionBuilder setSessionActivity(@Nullable PendingIntent pendingIntent)
    Sets a `PendingIntent` to launch an `Activity` for the `MediaSession`.
    Parameters:
      `pendingIntent` - The pending intent to be set
    Returns:
      This builder