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

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MediaSessionBuilder()` | Constructs default MediaSessionBuilder

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MediaSessionBuilder` | `setAllowedCommandProvider​(SessionCallbackBuilder.AllowedCommandProvider allowedCommandProvider)` | Sets the `SessionCallbackBuilder.AllowedCommandProvider` to provide allowed commands for controllers
    `MediaSessionBuilder` | `setCustomCommandProvider​(SessionCallbackBuilder.CustomCommandProvider customCommandProvider)` | Sets the `SessionCallbackBuilder.CustomCommandProvider` to handle incoming custom commands
    `MediaSessionBuilder` | `setDisconnectedCallback​(SessionCallbackBuilder.DisconnectedCallback disconnectedCallback)` | Sets the `SessionCallbackBuilder.DisconnectedCallback` to handle cleaning up controller
    `MediaSessionBuilder` | `setFastForwardIncrementMs​(int fastForwardMs)` | Sets the fast forward increment in milliseconds
    `MediaSessionBuilder` | `setMediaItemProvider​(SessionCallbackBuilder.MediaItemProvider mediaItemProvider)` | Sets the `SessionCallbackBuilder.MediaItemProvider` that will convert media ids to `MediaItems`
    `MediaSessionBuilder` | `setPostConnectCallback​(SessionCallbackBuilder.PostConnectCallback postConnectCallback)` | Sets the `SessionCallbackBuilder.PostConnectCallback` to handle extra initialization after the connection
    `MediaSessionBuilder` | `setRatingCallback​(SessionCallbackBuilder.RatingCallback ratingCallback)` | Sets the `SessionCallbackBuilder.RatingCallback` to handle user ratings
    `MediaSessionBuilder` | `setRewindIncrementMs​(int rewindMs)` | Sets the rewind increment in milliseconds
    `MediaSessionBuilder` | `setSeekTimeoutMs​(int seekTimeoutMs)` | Sets the timeout in milliseconds for fast forward and rewind operations, or `0` for no timeout.
    `MediaSessionBuilder` | `setSkipCallback​(SessionCallbackBuilder.SkipCallback skipCallback)` | Sets the `SessionCallbackBuilder.SkipCallback` to handle skip backward and skip forward

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

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

- - ### Constructor Detail

    - #### MediaSessionBuilder

          public MediaSessionBuilder()

      Constructs default MediaSessionBuilder

  - ### Method Detail

    - #### setRatingCallback

          public MediaSessionBuilder setRatingCallback​(@Nullable
                                                       SessionCallbackBuilder.RatingCallback ratingCallback)

      Sets the `SessionCallbackBuilder.RatingCallback` to handle user ratings
      Parameters:
        `ratingCallback` - A rating callback
      Returns:
        This builder

    - #### setCustomCommandProvider

          public MediaSessionBuilder setCustomCommandProvider​(@Nullable
                                                              SessionCallbackBuilder.CustomCommandProvider customCommandProvider)

      Sets the `SessionCallbackBuilder.CustomCommandProvider` to handle incoming custom commands
      Parameters:
        `customCommandProvider` - A custom command provider
      Returns:
        This builder

    - #### setMediaItemProvider

          public MediaSessionBuilder setMediaItemProvider​(@Nullable
                                                          SessionCallbackBuilder.MediaItemProvider mediaItemProvider)

      Sets the `SessionCallbackBuilder.MediaItemProvider` that will convert media ids to `MediaItems`
      Parameters:
        `mediaItemProvider` - The media item provider
      Returns:
        This builder

    - #### setAllowedCommandProvider

          public MediaSessionBuilder setAllowedCommandProvider​(@Nullable
                                                               SessionCallbackBuilder.AllowedCommandProvider allowedCommandProvider)

      Sets the `SessionCallbackBuilder.AllowedCommandProvider` to provide allowed commands for controllers
      Parameters:
        `allowedCommandProvider` - A allowed command provider
      Returns:
        This builder

    - #### setSkipCallback

          public MediaSessionBuilder setSkipCallback​(@Nullable
                                                     SessionCallbackBuilder.SkipCallback skipCallback)

      Sets the `SessionCallbackBuilder.SkipCallback` to handle skip backward and skip forward
      Parameters:
        `skipCallback` - The skip callback
      Returns:
        This builder

    - #### setPostConnectCallback

          public MediaSessionBuilder setPostConnectCallback​(@Nullable
                                                            SessionCallbackBuilder.PostConnectCallback postConnectCallback)

      Sets the `SessionCallbackBuilder.PostConnectCallback` to handle extra initialization after the connection
      Parameters:
        `postConnectCallback` - The post connect callback
      Returns:
        This builder

    - #### setDisconnectedCallback

          public MediaSessionBuilder setDisconnectedCallback​(@Nullable
                                                             SessionCallbackBuilder.DisconnectedCallback disconnectedCallback)

      Sets the `SessionCallbackBuilder.DisconnectedCallback` to handle cleaning up controller
      Parameters:
        `disconnectedCallback` - The disconnected callback
      Returns:
        This builder

    - #### setRewindIncrementMs

          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

          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

    - #### setSeekTimeoutMs

          public MediaSessionBuilder setSeekTimeoutMs​(int seekTimeoutMs)

      Sets the timeout in milliseconds for fast forward and rewind operations, or `0` for no timeout. If a timeout is set, controllers will receive an error if the session's call to `SessionPlayer.seekTo(long)` takes longer than this amount of time
      Parameters:
        `seekTimeoutMs` - A timeout for `SessionPlayer.seekTo(long)`. A non-positive value will wait forever
      Returns:
        This builder