Package com.castlabs.sdk.conviva

## Class ConvivaAnalyticsSession

- java.lang.Object
- - com.castlabs.analytics.AnalyticsSession
  - - com.castlabs.sdk.conviva.ConvivaAnalyticsSession

- All Implemented Interfaces:
    `IAnalyticsSession`, `PlayerControllerPlugin.Component`

      public class ConvivaAnalyticsSession
      extends AnalyticsSession

  This class allows to get `ConvivaVideoAnalytics` API access. You can get the instance with the `getVideoAnalytics()` method.

  To get the instance of this class use `PlayerController.getComponent(Class)` as follows:

       ConvivaAnalyticsSession convivaAnalyticsSession = playerView.getPlayerController().getComponent(ConvivaAnalyticsSession.class);

  To send a custom Conviva event do the following:

       if (convivaAnalyticsSession != null) {
           // Fill custom map
           HashMap<String, Object> customData = new HashMap<>();
           customData.put("now", Long.toString(System.currentTimeMillis()));
           customData.put("fizz", "buzz");

           String eventType = "customEvent";
           ConvivaVideoAnalytics videoAnalytics = convivaAnalyticsSession.getVideoAnalytics();
           // Send event
           if (videoAnalytics != null) {
             convivaAnalyticsSession.getVideoAnalytics().reportPlaybackEvent(eventType, customData);
           }
      }

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `META_KEY_APPLICATION_NAME` | Key that can be used to add applicationName to the analytics meta-data.
    `static String` | `META_KEY_DEFAULT_RESOURCE` | Key that can be used to add defaultResource to the analytics meta-data.
    `static String` | `META_KEY_ENCODED_FRAMERATE` | Key that can be used to add encodedFrameRate to the analytics meta-data.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `adErrorInternal​(CastlabsPlayerException exception)` |
    `void` | `adSkippedInternal()` |
    `void` | `adStartInternal​(Ad ad)` |
    `void` | `adStopInternal()` |
    `void` | `detachFromControllerInternal()` |
    `com.conviva.sdk.ConvivaAdAnalytics` | `getAdAnalytics()` | Getter for the Conviva ad analytics instance.
    `com.conviva.sdk.ConvivaVideoAnalytics` | `getVideoAnalytics()` | Getter for the Conviva Video Analytics instance, can be used to send custom player insight events associated with the video playback.
    `Class` | `id()` |
    `void` | `onDestroy​(PlayerController playerController)` |
    `void` | `onExoPlayerStateChangedInternal​(boolean playWhenReady, int playbackState)` |
    `void` | `onOpenBundle​(PlayerController playerController, Bundle bundle)` |
    `void` | `onOpenState​(PlayerController playerController, PlayerConfig playerConfig)` |
    `void` | `releaseInternal()` |
    `void` | `reportPlayerStateInternal​(PlayerController.State state)` |
    `void` | `seekEndInternal()` |
    `void` | `seekProcessedInternal()` |
    `void` | `seekStartInternal​(long newPosition)` |
    `void` | `sendErrorInternal​(String code, String message, int severity)` |
    `void` | `startInternal​(PlayerController playerController, AnalyticsMetaData analyticsMetaData)` |
    `void` | `stopInternal()` |

    - ### Methods inherited from class com.castlabs.analytics.AnalyticsSession

      `adError, adSkipped, adStart, adStop, detachFromController, getEnabled, onExoPlayerStateChanged, release, reportPlayerState, seekEnd, seekProcessed, seekStart, sendError, setEnabled, start, stop`

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

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

- - ### Field Detail

    - #### META_KEY_ENCODED_FRAMERATE

          public static final String META_KEY_ENCODED_FRAMERATE

      Key that can be used to add encodedFrameRate to the analytics meta-data. The value must be of type int.
      See Also:
        Constant Field Values

    - #### META_KEY_DEFAULT_RESOURCE

          public static final String META_KEY_DEFAULT_RESOURCE

      Key that can be used to add defaultResource to the analytics meta-data. The value must be of type String.
      See Also:
        Constant Field Values

    - #### META_KEY_APPLICATION_NAME

          public static final String META_KEY_APPLICATION_NAME

      Key that can be used to add applicationName to the analytics meta-data. The value must be of type String.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getVideoAnalytics

          @Nullable
          public com.conviva.sdk.ConvivaVideoAnalytics getVideoAnalytics()

      Getter for the Conviva Video Analytics instance, can be used to send custom player insight events associated with the video playback.
      Returns:
        The underlying instance of Conviva's `ConvivaVideoAnalytics`. null if session hasn't started yet, already released, or failed initialization.

    - #### getAdAnalytics

          @Nullable
          public com.conviva.sdk.ConvivaAdAnalytics getAdAnalytics()

      Getter for the Conviva ad analytics instance.

    - #### startInternal

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

    - #### stopInternal

          public void stopInternal()

    - #### releaseInternal

          public void releaseInternal()

    - #### detachFromControllerInternal

          public void detachFromControllerInternal()

    - #### onExoPlayerStateChangedInternal

          public void onExoPlayerStateChangedInternal​(boolean playWhenReady,
                                                      int playbackState)

    - #### id

          @NonNull
          public Class id()

    - #### onDestroy

          public void onDestroy​(@NonNull
                                PlayerController playerController)

    - #### onOpenBundle

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

    - #### onOpenState

          public void onOpenState​(PlayerController playerController,
                                  PlayerConfig playerConfig)

    - #### adStartInternal

          public void adStartInternal​(Ad ad)

    - #### adStopInternal

          public void adStopInternal()

    - #### adErrorInternal

          public void adErrorInternal​(CastlabsPlayerException exception)

    - #### adSkippedInternal

          public void adSkippedInternal()

    - #### reportPlayerStateInternal

          public void reportPlayerStateInternal​(PlayerController.State state)

    - #### sendErrorInternal

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

    - #### seekStartInternal

          public void seekStartInternal​(long newPosition)

    - #### seekEndInternal

          public void seekEndInternal()

    - #### seekProcessedInternal

          public void seekProcessedInternal()