Class 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(...);
    
          // Create AnalyticsMetadata and set it in the Bundle used to open the PlayerController
          AnalyticsMetaData analyticsMetaData = MuxPlugin.createMetadata(false, "lotr-1", videoData, playerData);
          bundle.put(SdkConsts.INTENT_ANALYTICS_DATA, analyticsMetaData);
    
          //...
    
          playerController.open(bundle)
     

    Since:
    4.1.19
    • Constructor Detail

      • 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

        public MuxPlugin​(@Nullable
                         String environmentKey,
                         boolean keepSessionInBackground)
        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 Detail

      • 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)
        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' CustomerViewData
        customerPlayerData - instance of Mux' CustomerPlayerData
        customerViewData - instance of Mux' CustomerViewData
        Returns:
        the AnalyticsMetaData
      • createMetadata

        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)
        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.