Class NielsenPlugin

java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.nielsen.NielsenPlugin

public class NielsenPlugin extends Plugin
This plugin integrates the Nielsen SDK. The plugin ensures that playback meta-data is send towards the Nielsen SDK and it allows you to access the Nielsen SDK instance.

The latter is important because the plugin can not track application lifecycle fully, so you need to integrate the callbacks when you application goes to background. The foreground callback is triggered automatically when the player view component is registered.

Before you can use this plugin, you have to register it with the SDK:

 
     PlayerSDK.register(new NielsenPlugin(...));
     PlayerSDK.init(getApplicationContext());
 
 

The plugin constructor takes either the mandatory parameters that are required for the Nielsen SDK, or you can pass a JSONObject. In the latter case, please make sure that you configure and setup the mandatory Nielsen parameters in the JSONObject manually.

Once registered, the NielsenComponent will be exposed by the PlayerView. The internals of that component will make sure that the Nielsen SDK is created and initialized and that playback data is forwarded correctly. You can however access the Nielsen AppSdk through that component to add additional lifecycle calls (i.e. app goes to background) or integrate the opt-in or opt-out support. Here is an example how you can access the component:

 
 NielsenComponent nielsenComponent = playerView.getComponent(NielsenComponent.class);
 if (nielsenComponent != null && nielsenComponent.getAppSdk() != null) {
   nielsenComponent.getAppSdk().appInForeground(this);
 }
 
 

The integration uses the AnalyticsMetaData extract and provide additional information downstream. The channel information contains the playback URL and uses the AnalyticsMetaData.assetId as the "channelName".

The content meta data will contain all keys in the AnalyticsMetaData.extra bundle and will always set the "assetId" and the "length" based on AnalyticsMetaData.assetId and AnalyticsMetaData.durationSeconds unless they are already defined in the extras. The duration for VoD (i.e. non live) content is also taken from the player controller if not specified in the analytics meta-data.

Besides the NielsenComponent, the plugin does also expose the instance of the AppSdk. This can be used for instance to handle opt-in/opt-out requests outside of playback. You can access the plugin dynamically after it was registered:

 
   NielsenPlugin nielsenPlugin = PlayerSDK.getPlugin(NielsenPlugin.class);
   AppSdk appSdk = nielsenPlugin.getAppSdk();
   ...
 
 
Since:
4.2.0
  • Field Details

    • SF_CODE_DCR

      public static final String SF_CODE_DCR
      The SF code for DCR
      See Also:
    • CONFIG_KEY_APPID

      public static final String CONFIG_KEY_APPID
      JSON Object configuration key for the app ID
      See Also:
    • CONFIG_KEY_APPNAME

      public static final String CONFIG_KEY_APPNAME
      JSON Object configuration key for the app name
      See Also:
    • CONFIG_KEY_APPVERSION

      public static final String CONFIG_KEY_APPVERSION
      JSON Object configuration key for the app version
      See Also:
    • CONFIG_KEY_SFCODE

      public static final String CONFIG_KEY_SFCODE
      JSON Object configuration key for the app SF Code
      See Also:
  • Constructor Details

    • NielsenPlugin

      public NielsenPlugin(String appId, String appName, String appVersion, String sfCode)
      Create a new instance of the plugin with the given app id, app name and sf code that will be passed to the Nielsen SDK.
      Parameters:
      appId - The App ID
      appName - The App Name
      appVersion - The App Version
      sfCode - The SF-Code
    • NielsenPlugin

      public NielsenPlugin(@NonNull JSONObject configuration)
      Create a new instance of the plugin using the given JSON Object to configure the Nielsen SDK
      Parameters:
      configuration - The configuration that will be passed to the Nielsen SDK
  • Method Details

    • getId

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

      public void setEnabled(boolean enabled)
      Dynamically enable or disable nielsen integration for playbacks
      Parameters:
      enabled - Enable or disable
    • getAppSdk

      @NonNull public NielsenComponent.AppSdk getAppSdk()
      Returns the instance of the App SDK
      Returns:
      The App SDK