Package com.castlabs.sdk.ima

# Class ImaPlugin

java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.ima.ImaPlugin

All Implemented Interfaces:
  `AdProvider`, `ClientAdProvider`

public class ImaPlugin extends Plugin implements ClientAdProvider
This plugin integrates Ads IMA SDK 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();

              ImaPlugin imaPlugin = new ImaPlugin();
              imaPlugin.setEnabled(true);

              // (Optional) Set the IMA SDK settings
              ImaSdkSettings imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings();
              imaSdkSettings.setLanguage("en");
              imaPlugin.setImaSdkSettings(imaSdkSettings);

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

Since:
  3.2.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `DISABLE_THRESHOLD_END_OF_CONTENT_MS`
  Set to `setThresholdEndOfContentMs(long)` in order to disable the threshold behaviour.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImaPlugin()`
  Create a new instance of this plugin using the default configuration.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AdLoader`
  `createAdLoader(AdRequest adRequest)`
  `Double`
  `getDefaultPlayAdsAfterTimeSec()`
  Get the default play-ads-after content time in seconds.
  `String`
  `getId()`
  `com.google.ads.interactivemedia.v3.api.ImaSdkSettings`
  `getImaSdkSettings()`
  Get previously installed instance of IMA SDK settings
  `String`
  `getName()`
  `static long`
  `getThresholdEndOfContentMs()`
  Get the threshold, in milliseconds
  `void`
  `setDefaultPlayAdsAfterTimeSec(Double secondsOrNull)`
  Set a default play-ads-after content time in seconds for client-side IMA.
  `void`
  `setEnabled(boolean enabled)`
  Enable or disable plugin.
  `void`
  `setImaSdkSettings(com.google.ads.interactivemedia.v3.api.ImaSdkSettings imaSdkSettings)`
  Set the IMA SDK settings instance used when creating the IMA `AdsLoader`
  `static void`
  `setThresholdEndOfContentMs(long thresholdEndOfContentMs)`
  Sets the threshold, in milliseconds, before the end of content at which IMA is notified that content is complete if the player buffers.

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

  `init, onRemotePlay`

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

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

- ## Field Details

  - ### DISABLE_THRESHOLD_END_OF_CONTENT_MS

    public static final long DISABLE_THRESHOLD_END_OF_CONTENT_MS
    Set to `setThresholdEndOfContentMs(long)` in order to disable the threshold behaviour. This is the default value.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ImaPlugin

    public ImaPlugin()
    Create a new instance of this plugin using the default configuration.

- ## Method Details

  - ### getId

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

  - ### createAdLoader

    @NonNull public AdLoader createAdLoader(@Nullable AdRequest adRequest)
    Specified by:
      `createAdLoader` in interface `ClientAdProvider`

  - ### getName

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

  - ### setEnabled

    public void setEnabled(boolean enabled)
    Enable or disable plugin.
    Parameters:
      `enabled` - Enable or disable the plugin

  - ### setImaSdkSettings

    public void setImaSdkSettings(@Nullable com.google.ads.interactivemedia.v3.api.ImaSdkSettings imaSdkSettings)
    Set the IMA SDK settings instance used when creating the IMA `AdsLoader`
    Parameters:
      `imaSdkSettings` - or `null`

  - ### getImaSdkSettings

    @Nullable public com.google.ads.interactivemedia.v3.api.ImaSdkSettings getImaSdkSettings()
    Get previously installed instance of IMA SDK settings
    Returns:
      instance of IMA SDK settings or `null`

  - ### setDefaultPlayAdsAfterTimeSec

    public void setDefaultPlayAdsAfterTimeSec(@Nullable Double secondsOrNull)
    Set a default play-ads-after content time in seconds for client-side IMA. Applied only if the individual `ImaAdRequest` does not specify it.
    Parameters:
      `secondsOrNull` - Seconds (>= 0) or `null` to unset the default.

  - ### getDefaultPlayAdsAfterTimeSec

    @Nullable public Double getDefaultPlayAdsAfterTimeSec()
    Get the default play-ads-after content time in seconds.
    Returns:
      Seconds or `null` if unset.

  - ### setThresholdEndOfContentMs

    public static void setThresholdEndOfContentMs(long thresholdEndOfContentMs)
    Sets the threshold, in milliseconds, before the end of content at which IMA is notified that content is complete if the player buffers. Set to `DISABLE_THRESHOLD_END_OF_CONTENT_MS` to disable the threshold behavior.
    Parameters:
      `thresholdEndOfContentMs` - The threshold in milliseconds or `DISABLE_THRESHOLD_END_OF_CONTENT_MS`

  - ### getThresholdEndOfContentMs

    public static long getThresholdEndOfContentMs()
    Get the threshold, in milliseconds
    Returns:
      The threshold in milliseconds or @link #DISABLE_THRESHOLD_END_OF_CONTENT_MS}