Package com.castlabs.sdk.broadpeak

# Class BroadpeakPlugin

java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.broadpeak.BroadpeakPlugin

All Implemented Interfaces:
  `AdProvider`, `ServerAdProvider`

public class BroadpeakPlugin extends Plugin implements ServerAdProvider
This plugin integrates Broadpeak Analytics with the Castlabs Player SDK. You can enable and register the plugin before you initialize the SDK:

      private static final String ANALYTICS_URL = "http://48.15.16.23";

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

              BroadpeakPlugin broadpeak = new BroadpeakPlugin(ANALYTICS_URL, NANO_CDN_HOST, DOMAIN_NAMES);

              PlayerSDK.register(broadpeak);
              PlayerSDK.init(getApplicationContext());
          }
     }

Since:
  4.1.8

- ## Nested Class Summary

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `AD_PROVIDER_NAME`
  Identifier used to register Broadpeak as an ad provider with `Adverts`.
  `static boolean`
  `adTracking`
  Indicates whether to enable Broadpeak's advertising.
  `static boolean`
  `DEFAULT_PRECACHE`
  Whether to enable Broadpeak precaching as default when creating a Session.
  `static int`
  `SESSION_START_RETRIES`
  Number of retries to start a session.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BroadpeakPlugin(String analyticsUrl, String nanoCDNHost, String broadpeakDomainNames)`
  Creates a new instance of `BroadpeakPlugin`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ServerAdLoader`
  `createAdLoader(PlayerConfig config)`
  `static AnalyticsMetaData`
  `createMetadata(boolean live, String assetId, Bundle customParameters, SparseArray<Object> options)`
  Deprecated.
  Use `BroadpeakPlugin.MetadataBuilder` instead.
  `static AnalyticsMetaData`
  `createMetadata(AnalyticsMetaData analyticsMetaData, Bundle customParameters, SparseArray<Object> options)`
  Deprecated.
  Use `BroadpeakPlugin.MetadataBuilder` instead.
  `String`
  `getId()`
  `String`
  `getName()`
  `void`
  `init(Context context)`
  `void`
  `setEnabled(boolean enabled)`
  Enables or disables the BroadpeakPlugin.

  ### Methods inherited from class com.castlabs.android.Plugin

  `onRemotePlay`

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

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

- ## Field Details

  - ### AD_PROVIDER_NAME

    public static final String AD_PROVIDER_NAME
    Identifier used to register Broadpeak as an ad provider with `Adverts`.
    See Also:
      - Constant Field Values

  - ### SESSION_START_RETRIES

    public static int SESSION_START_RETRIES
    Number of retries to start a session. Default is 3.

  - ### DEFAULT_PRECACHE

    public static boolean DEFAULT_PRECACHE
    Whether to enable Broadpeak precaching as default when creating a Session.

    Note that if `BroadpeakPlugin.MetadataBuilder.precache(boolean)` is informed, it will override this default value.

  - ### adTracking

    public static boolean adTracking
    Indicates whether to enable Broadpeak's advertising. Default is false.

- ## Constructor Details

  - ### BroadpeakPlugin

    public BroadpeakPlugin(@Nullable String analyticsUrl, @Nullable String nanoCDNHost, @Nullable String broadpeakDomainNames)
    Creates a new instance of `BroadpeakPlugin`.
    Parameters:
      `analyticsUrl` - Host where to send analytics. Can be null if the analytics service is not to be used.
      `nanoCDNHost` - Broadpeak's Nano CDN Host. Can be null.
      `broadpeakDomainNames` - Broadpeak Domain Names. If null, the default ("*") will be used.

- ## Method Details

  - ### setEnabled

    public void setEnabled(boolean enabled)
    Enables or disables the BroadpeakPlugin. Note that this has to be set to the desired value *before* the `PlayerController` creation. Default is true.
    Parameters:
      `enabled` - whether to enable the plugin or not.

  - ### init

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

  - ### createAdLoader

    @Nullable public ServerAdLoader createAdLoader(@NonNull PlayerConfig config)
    Specified by:
      `createAdLoader` in interface `ServerAdProvider`

  - ### getName

    @NonNull public String getName()
    Specified by:
      `getName` in interface `AdProvider`

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(boolean live, @NonNull String assetId, @Nullable Bundle customParameters, @Nullable SparseArray<Object> options)
    Deprecated.
    Use `BroadpeakPlugin.MetadataBuilder` instead.
    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
      `customParameters` - Custom Broadpeak parameters, which will be added to the `StreamingSession`. The params must be String values. Can be null.
      `options` - Custom Broadpeak options, which will be added to the `StreamingSession`. Keys for these options are declared in `StreamingSessionOptions`. Values must be boolean, int or String. Can be null.
    Returns:
      Created analytics metadata

  - ### createMetadata

    @NonNull @Deprecated public static AnalyticsMetaData createMetadata(@NonNull AnalyticsMetaData analyticsMetaData, @Nullable Bundle customParameters, @Nullable SparseArray<Object> options)
    Deprecated.
    Use `BroadpeakPlugin.MetadataBuilder` instead.
    Update provided analytics metadata with extra Broadpeak metadata
    Parameters:
      `analyticsMetaData` - Existing AnalyticsMetadata where to add Broadpeak metadata
      `customParameters` - Custom Broadpeak parameters, which will be added to the `StreamingSession`. The params must be String values. Can be null.
      `options` - Custom Broadpeak options, which will be added to the `StreamingSession`. Keys for these options are declared in `StreamingSessionOptions`. Values must be boolean, int or String. Can be null.
    Returns:
      Updated analytics metadata

  - ### getId

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