Package com.castlabs.sdk.mux

# Class MuxPlugin

java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.mux.MuxPlugin

public class MuxPlugin extends Plugin
This plugin integrates MUX Data 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();

              MuxPlugin muxPlugin = new MuxPlugin(MUX_API_KEY);
              PlayerSDK.register(muxPlugin);

              PlayerSDK.init(getApplicationContext());
          }
     }

Then, upon playback start, you should inform `AnalyticsMetaData` field when `opening` the Controller:

          //...

          // Create MUX CustomerData, fill in metadata
          CustomerVideoData videoData = new CustomerVideoData();
          videoData.setVideoTitle("The Lord of the Rings");
          videoData.setVideoLanguageCode("en");
          //videoData.setVideoProducer(...);
          //videoData.setVideoEncodingVariant(...);

          // Create MUX PlayerData, fill in metadata
          CustomerPlayerData playerData = new CustomerPlayerData();
          playerData.setViewerUserId("userId");
          //playerData.setExperimentName(...);

          CustomerData customerData = new CustomerData();
          customerData.setCustomerVideoData(videoData);
          customerData.setCustomerPlayerData(playerData);

          // Create AnalyticsMetadata and set it in the Bundle used to open the PlayerController
          AnalyticsMetaData analyticsMetaData = new MuxPlugin.MetadataBuilder(false, "lotr-1")
              .customerData(customerData)
              .get();
          bundle.put(SdkConsts.INTENT_ANALYTICS_DATA, analyticsMetaData);

          //...

          playerController.open(bundle)

Since:
  4.1.19

- ## Nested Class Summary

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MuxPlugin()`
  Create a Mux Plugin with null Environment Key.
  `MuxPlugin(String environmentKey)`
  Create Mux Plugin with the given Environment Key, or null.
  `MuxPlugin(String environmentKey, boolean keepSessionInBackground)`
  Deprecated.
  Register the plugin with `MuxPlugin(String)` and configure background retention for each playback with `MuxPlugin.MetadataBuilder.keepSessionInBackground(boolean)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AnalyticsMetaData`
  `createMetadata(boolean live, String assetId, com.mux.stats.sdk.core.model.CustomerData customerData, com.mux.stats.sdk.core.CustomOptions customOptions, AnalyticsMetaData analyticsMetaData)`
  Deprecated.
  Use `MuxPlugin.MetadataBuilder` instead.
  `static AnalyticsMetaData`
  `createMetadata(boolean live, String assetId, com.mux.stats.sdk.core.model.CustomerVideoData customerVideoData, com.mux.stats.sdk.core.model.CustomerPlayerData customerPlayerData, com.mux.stats.sdk.core.model.CustomerViewData customerViewData)`
  Deprecated.
  Use `MuxPlugin.MetadataBuilder` instead.
  `String`
  `getId()`

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

- ## Constructor Details

  - ### MuxPlugin

    public MuxPlugin()
    Create a Mux Plugin with null Environment Key.

  - ### MuxPlugin

    public MuxPlugin(@Nullable String environmentKey)
    Create Mux Plugin with the given Environment Key, or null. If null is passed, you must inform the Environment Key upon playback start through Mux's PlayerData. Even if an Environment Key is informed here, it may be later overridden on playback start. The plugin is constructed that the session is not kept alive when the app is backgrounded.
    Parameters:
      `environmentKey` - the Environment Key to use, or null.

  - ### MuxPlugin

    @Deprecated public MuxPlugin(@Nullable String environmentKey, boolean keepSessionInBackground)
    Deprecated.
    Register the plugin with `MuxPlugin(String)` and configure background retention for each playback with `MuxPlugin.MetadataBuilder.keepSessionInBackground(boolean)`. The value supplied to this constructor remains the fallback for metadata without an explicit retention setting.
    Create Mux Plugin with the given Environment Key and keepSessionInBackground value.
    Parameters:
      `environmentKey` - the Environment Key to use, or null.
      `keepSessionInBackground` - the flag which defines whether the session should be kept alive when the app is backgrounded.

- ## Method Details

  - ### getId

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

  - ### createMetadata

    @Deprecated public static AnalyticsMetaData createMetadata(boolean live, @NonNull String assetId, @Nullable com.mux.stats.sdk.core.model.CustomerVideoData customerVideoData, @Nullable com.mux.stats.sdk.core.model.CustomerPlayerData customerPlayerData, @Nullable com.mux.stats.sdk.core.model.CustomerViewData customerViewData)
    Deprecated.
    Use `MuxPlugin.MetadataBuilder` instead.
    Create an `AnalyticsMetaData` object with the provided Mux Data
    Parameters:
      `live` - whether the asset is a live stream or not
      `assetId` - unique asset identifier
      `customerVideoData` - instance of Mux' `CustomerVideoData`
      `customerPlayerData` - instance of Mux' `CustomerPlayerData`
      `customerViewData` - instance of Mux' `CustomerViewData`
    Returns:
      the `AnalyticsMetaData`

  - ### createMetadata

    @Deprecated public static AnalyticsMetaData createMetadata(boolean live, @NonNull String assetId, @NonNull com.mux.stats.sdk.core.model.CustomerData customerData, @Nullable com.mux.stats.sdk.core.CustomOptions customOptions, @Nullable AnalyticsMetaData analyticsMetaData)
    Deprecated.
    Use `MuxPlugin.MetadataBuilder` instead.
    Return an `AnalyticsMetaData` object with the provided Mux Data.
    Parameters:
      `live` - whether the asset is a live stream or not
      `assetId` - unique asset identifier
      `customerData` - instance of Mux' `CustomerData`
      `customOptions` - instance of Mux' `CustomOptions`
      `analyticsMetaData` - optional existing instance of `AnalyticsMetaData` to add the Mux Data to. If null is provided a new instance will be created
    Returns:
      the `AnalyticsMetaData` instance.