Package com.castlabs.sdk.conviva

# Class ConvivaPlugin

java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.conviva.ConvivaPlugin

public class ConvivaPlugin extends Plugin
This plugin integrates Conviva Analytics with the Castlabs Player SDK. You can enable and register the plugin before you initialize the SDK:

      public class MyApp extends Application {
         @Override
          public void onCreate() {
              super.onCreate();

              ConvivaPlugin convivaPlugin = new ConvivaPlugin(C.CONVIVA_CUSTOMER_KEY);
              if (BuildConfig.DEBUG) {
                  HashMap<String, Object> settings = new HashMap<>();
                        settings.put(ConvivaSdkConstants.GATEWAY_URL, C.CONVIVA_TOUCHSTONE_GATEWAY);
                        settings.put(ConvivaSdkConstants.LOG_LEVEL, ConvivaSdkConstants.LogLevel.DEBUG);
                        convivaPlugin.setSettings(settings);
              }
              HashMap<String, String> deviceInfo = new HashMap<>();
              final String prefix = "Test: ";
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.ANROID_BUILD_MODEL, prefix + ConvivaSdkConstants.DEVICEINFO.ANROID_BUILD_MODEL);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.OPERATING_SYSTEM_VERSION, prefix + ConvivaSdkConstants.DEVICEINFO.OPERATING_SYSTEM_VERSION);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_BRAND, prefix + ConvivaSdkConstants.DEVICEINFO.DEVICE_BRAND);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_MANUFACTURER, prefix + ConvivaSdkConstants.DEVICEINFO.DEVICE_MANUFACTURER);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_MODEL, prefix + ConvivaSdkConstants.DEVICEINFO.DEVICE_MODEL);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_TYPE, prefix + ConvivaSdkConstants.DEVICEINFO.DEVICE_TYPE);
              deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_VERSION, prefix + ConvivaSdkConstants.DEVICEINFO.DEVICE_VERSION);
              convivaPlugin.setDeviceInfo(deviceInfo);
              PlayerSDK.register(convivaPlugin);

              PlayerSDK.init(getApplicationContext());
          }
     }

Please note that you can customize the client settings (see `setSettings(Map)`) and the system settings (see `setDeviceInfo(Map)`) before you register the plugin.

Since:
  3.1.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `ConvivaPlugin.MetadataBuilder`
  A helper class to build `AnalyticsMetaData` objects for the Conviva plugin.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConvivaPlugin(String convivaCustomerKey)`
  Create the plugin

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AnalyticsMetaData`
  `createMetadata(boolean live, String assetId, String viewerId, Bundle bundle, Bundle customTags)`
  Deprecated.
  Use `ConvivaPlugin.MetadataBuilder`.
  `static AnalyticsMetaData`
  `createMetadata(boolean live, String assetId, String viewerId, Bundle bundle, Bundle customTags, Bundle adTags)`
  Deprecated.
  Use `ConvivaPlugin.MetadataBuilder`.
  `static AnalyticsMetaData`
  `createMetadata(Bundle bundle, AnalyticsMetaData analyticsMetaData, Bundle customTags)`
  Deprecated.
  Use `ConvivaPlugin.MetadataBuilder`.
  `static AnalyticsMetaData`
  `createMetadata(Bundle bundle, AnalyticsMetaData analyticsMetaData, Bundle customTags, Bundle adTags)`
  Deprecated.
  Use `ConvivaPlugin.MetadataBuilder`.
  `String`
  `getId()`
  `void`
  `init(Context context)`
  `void`
  `onRemotePlay(Bundle localConfiguration, JSONObject remoteConfiguration)`
  `void`
  `setDeviceInfo(Map<String,Object> deviceInfo)`
  Set the device info
  `void`
  `setEnabled(boolean enabled)`
  Enable or disable the plugin
  `void`
  `setSettings(Map<String,Object> settings)`
  Set the Conviva settings, used for debugging purposes

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

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

- ## Constructor Details

  - ### ConvivaPlugin

    public ConvivaPlugin(@NonNull String convivaCustomerKey)
    Create the plugin
    Parameters:
      `convivaCustomerKey` - The Conviva customer key, should not be null

- ## Method Details

  - ### init

    public void init(Context context)
    Overrides:
      `init` in class `Plugin`

  - ### getId

    @NonNull public String getId()
    Specified by:
      `getId` in class `Plugin`

  - ### setSettings

    public void setSettings(@NonNull Map<String,Object> settings)
    Set the Conviva settings, used for debugging purposes

    Note: Make sure calling this method is done before you register the plugin, otherwise the settings might now have an effect
    Parameters:
      `settings` - The settings

  - ### setDeviceInfo

    public void setDeviceInfo(@NonNull Map<String,Object> deviceInfo)
    Set the device info

    Note: Make sure calling this method is done before you register the plugin, otherwise the device info might now have an effect
    Parameters:
      `deviceInfo` - The device info

  - ### setEnabled

    public void setEnabled(boolean enabled)
    Enable or disable the plugin
    Parameters:
      `enabled` - true If the plugin is enabled and false otherwise

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(boolean live, @NonNull String assetId, @Nullable String viewerId, @Nullable Bundle bundle, @Nullable Bundle customTags)
    Deprecated.
    Use `ConvivaPlugin.MetadataBuilder`.
    Create analytics metadata based on provided data
    Parameters:
      `live` - true if the current content is a live stream and false otherwise
      `assetId` - The asset ID uniquely identifies the content
      `viewerId` - An identifier for the current User. Will override ConvivaSdkConstants.VIEWER_ID if not null
      `bundle` - Optional parameters. Custom tags should be in the following Bundle
      `customTags` - custom tags, or null
    Returns:
      Created analytics metadata

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(boolean live, @NonNull String assetId, @Nullable String viewerId, @Nullable Bundle bundle, @Nullable Bundle customTags, @Nullable Bundle adTags)
    Deprecated.
    Use `ConvivaPlugin.MetadataBuilder`.
    Create analytics metadata based on provided data
    Parameters:
      `live` - true if the current content is a live stream and false otherwise
      `assetId` - The asset ID uniquely identifies the content
      `viewerId` - An identifier for the current User. Will override ConvivaSdkConstants.VIEWER_ID if not null
      `bundle` - Optional parameters. Custom tags should be in the following Bundle
      `customTags` - custom tags, or null
      `adTags` - ad tags, or null
    Returns:
      Created analytics metadata

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(@NonNull Bundle bundle, @NonNull AnalyticsMetaData analyticsMetaData, @Nullable Bundle customTags)
    Deprecated.
    Use `ConvivaPlugin.MetadataBuilder`.
    Update provided analytics metadata with extra values from bundle
    Parameters:
      `bundle` - The bundle where all extra values are set
      `analyticsMetaData` - Initial metadata to update with extra values
      `customTags` - custom tags, or null
    Returns:
      Updated analytics metadata

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(@NonNull Bundle bundle, @NonNull AnalyticsMetaData analyticsMetaData, @Nullable Bundle customTags, @Nullable Bundle adTags)
    Deprecated.
    Use `ConvivaPlugin.MetadataBuilder`.
    Update provided analytics metadata with extra values from bundle
    Parameters:
      `bundle` - The bundle where all extra values are set
      `analyticsMetaData` - Initial metadata to update with extra values
      `customTags` - custom tags, or null
      `adTags` - ad tags, or null
    Returns:
      Updated analytics metadata

  - ### onRemotePlay

    public void onRemotePlay(@NonNull Bundle localConfiguration, @NonNull JSONObject remoteConfiguration)
    Overrides:
      `onRemotePlay` in class `Plugin`