Package com.castlabs.sdk.vimond

## Class VimondComponent

- java.lang.Object
- - com.castlabs.sdk.vimond.VimondComponent

- All Implemented Interfaces:
    `AnalyticsSession`, `PlayerControllerPlugin.Component`, `PlayerListener`, `VimondCallback`

      public class VimondComponent
      extends Object
      implements AnalyticsSession, VimondCallback, PlayerListener

  Main Vimond Plugin interaction point.

  To get an instance of the component, use the `PlayerController.getComponent(Class)`.

  The component can be used to register a `VimondCallback`. In addition, a new authentication token can be provided at runtime via `setToken(String)`.

           VimondComponent vimond = playerController.getComponent(VimondComponent.class);
           vimond.setRaiseErrorOnUnreachableHost(true); // Fail if host unreachable
           vimond.setRaiseErrorOnInvalidStatusCode(true); // Fail if bad http status code is received
           vimond.setCallback(new VimondCallback() {
                      @Override
                      public void onVimondResponse(int httpStatusCode,
                                                   @Nullable Map<String, List<String>> headers,
                                                   @Nullable String responseBody) {
                           Log.d(TAG, "Vimond response (" + httpStatusCode + ") " + responseBody);
                      }
           });

  Since:
    4.2.34

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `adError​(CastlabsPlayerException exception)` |
    `void` | `adSkipped()` |
    `void` | `adStart​(Ad ad)` |
    `void` | `adStop()` |
    `void` | `detachFromController()` |
    `Class` | `id()` |
    `void` | `onDestroy​(PlayerController playerController)` |
    `void` | `onDisplayChanged​(DisplayInfo displayInfo, boolean canPlay)` |
    `void` | `onDurationChanged​(long durationUs)` |
    `void` | `onError​(CastlabsPlayerException error)` |
    `void` | `onExoPlayerStateChanged​(boolean playWhenReady, int playbackState)` |
    `void` | `onFatalErrorOccurred​(CastlabsPlayerException error)` |
    `void` | `onFullyBuffered()` |
    `void` | `onOpenBundle​(PlayerController playerController, Bundle bundle)` |
    `void` | `onOpenState​(PlayerController playerController, PlayerConfig playerConfig)` |
    `void` | `onPlaybackPositionChanged​(long playbackPositionMs)` |
    `void` | `onPlayerModelChanged()` |
    `void` | `onSeekCompleted()` |
    `void` | `onSeekRangeChanged​(long startTimeMs, long endTimeMs)` |
    `void` | `onSeekTo​(long newPosition)` |
    `void` | `onSpeedChanged​(float speed)` |
    `void` | `onStateChanged​(PlayerController.State state)` |
    `void` | `onTrackKeyStatusChanged()` |
    `void` | `onVideoSizeChanged​(int width, int height, float pixelWidthHeightRatio)` |
    `void` | `onVimondResponse​(int httpStatusCode, Map<String,​List<String>> headers, String responseBody)` | Will be called on each an every Vimond backend response, regardless of the status code.
    `void` | `release()` |
    `void` | `seekEnd()` |
    `void` | `seekProcessed()` |
    `void` | `seekStart​(long newPosition)` |
    `void` | `sendError​(String code, String message, int severity)` |
    `void` | `setCallback​(VimondCallback callback)` | Set the `VimondCallback` to invoke on each Vimond backend response.
    `void` | `setRaiseErrorOnInvalidStatusCode​(boolean value)` | Whether to throw a fatal Exception if the Vimond backend answers with an invalid HTTP code (400, 401, 403).
    `void` | `setRaiseErrorOnUnreachableHost​(boolean value)` | Whether to throw a fatal Exception if the Vimond backend is unreachable.
    `void` | `setToken​(String token)` | Set a new token for authentication purposes.
    `void` | `start​(PlayerController playerController, AnalyticsMetaData analyticsMetaData)` |
    `void` | `stop()` |

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

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

- - ### Method Detail

    - #### start

          public void start​(@NonNull
                            PlayerController playerController,
                            @NonNull
                            AnalyticsMetaData analyticsMetaData)

      Specified by:
        `start` in interface `AnalyticsSession`

    - #### stop

          public void stop()

      Specified by:
        `stop` in interface `AnalyticsSession`

    - #### setCallback

          public void setCallback​(@Nullable
                                  VimondCallback callback)

      Set the `VimondCallback` to invoke on each Vimond backend response. The callback will also be invoked even if the plugin decides to shutdown playback by raising an error.
      Parameters:
        `callback` - the callback to set

    - #### setToken

          public void setToken​(@NonNull
                               String token)

      Set a new token for authentication purposes. All network requests to Vimond backend will use the provided token.
      Parameters:
        `token` - the token to use

    - #### setRaiseErrorOnUnreachableHost

          public void setRaiseErrorOnUnreachableHost​(boolean value)

      Whether to throw a fatal Exception if the Vimond backend is unreachable. true by default. The Exception thrown will have `CastlabsPlayerException.TYPE_CSL_NETWORK_ERROR` as its `type`.
      Parameters:
        `value` - the value

    - #### setRaiseErrorOnInvalidStatusCode

          public void setRaiseErrorOnInvalidStatusCode​(boolean value)

      Whether to throw a fatal Exception if the Vimond backend answers with an invalid HTTP code (400, 401, 403). true by default. The Exception thrown will have `CastlabsPlayerException.TYPE_CSL_LIMIT_REACHED` as its `type`.
      Parameters:
        `value` - the value

    - #### onVimondResponse

          public void onVimondResponse​(int httpStatusCode,
                                       @NonNull
                                       Map<String,​List<String>> headers,
                                       @Nullable
                                       String responseBody)

      Description copied from interface: `VimondCallback`
      Will be called on each an every Vimond backend response, regardless of the status code.
      Specified by:
        `onVimondResponse` in interface `VimondCallback`
      Parameters:
        `httpStatusCode` - the HTTP status code Vimond backend responded with, or -1 if couldn't get a response.
        `headers` - response headers, if applicable.
        `responseBody` - response body, if applicable.

    - #### adStart

          public void adStart​(Ad ad)

      Specified by:
        `adStart` in interface `AnalyticsSession`

    - #### adStop

          public void adStop()

      Specified by:
        `adStop` in interface `AnalyticsSession`

    - #### adError

          public void adError​(CastlabsPlayerException exception)

      Specified by:
        `adError` in interface `AnalyticsSession`

    - #### adSkipped

          public void adSkipped()

      Specified by:
        `adSkipped` in interface `AnalyticsSession`

    - #### sendError

          public void sendError​(String code,
                                String message,
                                int severity)

      Specified by:
        `sendError` in interface `AnalyticsSession`

    - #### seekStart

          public void seekStart​(long newPosition)

      Specified by:
        `seekStart` in interface `AnalyticsSession`

    - #### seekEnd

          public void seekEnd()

      Specified by:
        `seekEnd` in interface `AnalyticsSession`

    - #### seekProcessed

          public void seekProcessed()

      Specified by:
        `seekProcessed` in interface `AnalyticsSession`

    - #### detachFromController

          public void detachFromController()

      Specified by:
        `detachFromController` in interface `AnalyticsSession`

    - #### release

          public void release()

      Specified by:
        `release` in interface `AnalyticsSession`

    - #### onExoPlayerStateChanged

          public void onExoPlayerStateChanged​(boolean playWhenReady,
                                              int playbackState)

      Specified by:
        `onExoPlayerStateChanged` in interface `AnalyticsSession`

    - #### id

          @NonNull
          public Class id()

      Specified by:
        `id` in interface `PlayerControllerPlugin.Component`

    - #### onDestroy

          public void onDestroy​(@NonNull
                                PlayerController playerController)

      Specified by:
        `onDestroy` in interface `PlayerControllerPlugin.Component`

    - #### onOpenBundle

          public void onOpenBundle​(@NonNull
                                   PlayerController playerController,
                                   @NonNull
                                   Bundle bundle)

      Specified by:
        `onOpenBundle` in interface `PlayerControllerPlugin.Component`

    - #### onOpenState

          public void onOpenState​(PlayerController playerController,
                                  PlayerConfig playerConfig)

      Specified by:
        `onOpenState` in interface `PlayerControllerPlugin.Component`

    - #### onFatalErrorOccurred

          public void onFatalErrorOccurred​(@NonNull
                                           CastlabsPlayerException error)

      Specified by:
        `onFatalErrorOccurred` in interface `PlayerListener`

    - #### onError

          public void onError​(@NonNull
                              CastlabsPlayerException error)

      Specified by:
        `onError` in interface `PlayerListener`

    - #### onStateChanged

          public void onStateChanged​(@NonNull
                                     PlayerController.State state)

      Specified by:
        `onStateChanged` in interface `PlayerListener`

    - #### onSeekTo

          public void onSeekTo​(long newPosition)

      Specified by:
        `onSeekTo` in interface `PlayerListener`

    - #### onSeekCompleted

          public void onSeekCompleted()

      Specified by:
        `onSeekCompleted` in interface `PlayerListener`

    - #### onVideoSizeChanged

          public void onVideoSizeChanged​(int width,
                                         int height,
                                         float pixelWidthHeightRatio)

      Specified by:
        `onVideoSizeChanged` in interface `PlayerListener`

    - #### onSeekRangeChanged

          public void onSeekRangeChanged​(long startTimeMs,
                                         long endTimeMs)

      Specified by:
        `onSeekRangeChanged` in interface `PlayerListener`

    - #### onPlaybackPositionChanged

          public void onPlaybackPositionChanged​(long playbackPositionMs)

      Specified by:
        `onPlaybackPositionChanged` in interface `PlayerListener`

    - #### onDisplayChanged

          public void onDisplayChanged​(DisplayInfo displayInfo,
                                       boolean canPlay)

      Specified by:
        `onDisplayChanged` in interface `PlayerListener`

    - #### onDurationChanged

          public void onDurationChanged​(long durationUs)

      Specified by:
        `onDurationChanged` in interface `PlayerListener`

    - #### onSpeedChanged

          public void onSpeedChanged​(float speed)

      Specified by:
        `onSpeedChanged` in interface `PlayerListener`

    - #### onPlayerModelChanged

          public void onPlayerModelChanged()

      Specified by:
        `onPlayerModelChanged` in interface `PlayerListener`

    - #### onTrackKeyStatusChanged

          public void onTrackKeyStatusChanged()

      Specified by:
        `onTrackKeyStatusChanged` in interface `PlayerListener`

    - #### onFullyBuffered

          public void onFullyBuffered()

      Specified by:
        `onFullyBuffered` in interface `PlayerListener`