Package com.castlabs.sdk.conviva

## Class ConvivaAnalyticsSession

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

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

      public class ConvivaAnalyticsSession
      extends Object
      implements 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` | `adError​(CastlabsPlayerException exception)` |
    `void` | `adSkipped()` |
    `void` | `adStart​(Ad ad)` |
    `void` | `adStop()` |
    `void` | `detachFromController()` |
    `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` | `onExoPlayerStateChanged​(boolean playWhenReady, int playbackState)` |
    `void` | `onOpenBundle​(PlayerController playerController, Bundle bundle)` |
    `void` | `onOpenState​(PlayerController playerController, PlayerConfig playerConfig)` |
    `void` | `release()` |
    `void` | `seekEnd()` |
    `void` | `seekProcessed()` |
    `void` | `seekStart​(long newPosition)` |
    `void` | `sendError​(String code, String message, int severity)` |
    `void` | `start​(PlayerController playerController, AnalyticsMetaData analyticsMetaData)` |
    `void` | `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.

    - #### 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`

    - #### release

          public void release()

      Specified by:
        `release` in interface `AnalyticsSession`

    - #### detachFromController

          public void detachFromController()

      Specified by:
        `detachFromController` 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`

    - #### 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`