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`, `SingleControllerPlaylist.PlaylistListener`

public class ConvivaAnalyticsSession extends AnalyticsSession implements SingleControllerPlaylist.PlaylistListener

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 final String`
  `META_KEY_APPLICATION_NAME`
  Key that can be used to add applicationName to the analytics meta-data.
  `static final String`
  `META_KEY_DEFAULT_RESOURCE`
  Key that can be used to add defaultResource to the analytics meta-data.
  `static final String`
  `META_KEY_ENCODED_FRAMERATE`
  Key that can be used to add encodedFrameRate to the analytics meta-data.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `adErrorInternal(Ad ad, CastlabsPlayerException exception)`
  `void`
  `adSkippedInternal()`
  `void`
  `adStartInternal(Ad ad)`
  `void`
  `adStopInternal()`
  `void`
  `adWillStartInternal(Ad ad)`
  `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`
  `onItemChange(PlayerConfig config)`
  `void`
  `onOpenBundle(PlayerController playerController, Bundle bundle)`
  `void`
  `onOpenState(PlayerController playerController, PlayerConfig playerConfig)`
  `void`
  `onPlaylistEnded()`
  `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

  `adClick, adError, adPause, adResume, adSkipped, adStart, adStop, adWillStart, 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 Details

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

  - ### 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.
    Returns:
      The underlying instance of Conviva's `ConvivaAdAnalytics`. null if session hasn't started

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

  - ### adWillStartInternal

    public void adWillStartInternal(Ad ad)

  - ### adStartInternal

    public void adStartInternal(Ad ad)

  - ### adStopInternal

    public void adStopInternal()

  - ### adErrorInternal

    public void adErrorInternal(Ad ad, 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()

  - ### onItemChange

    public void onItemChange(@NonNull PlayerConfig config)
    Specified by:
      `onItemChange` in interface `SingleControllerPlaylist.PlaylistListener`

  - ### onPlaylistEnded

    public void onPlaylistEnded()
    Specified by:
      `onPlaylistEnded` in interface `SingleControllerPlaylist.PlaylistListener`