package com.castlabs.sdk.youbora_demo;

import androidx.multidex.MultiDexApplication;

import com.castlabs.android.PlayerSDK;
import com.castlabs.sdk.ima.ImaPlugin;
import com.castlabs.sdk.youbora.YouboraPlugin;
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
import com.npaw.youbora.lib6.YouboraLog;
import com.npaw.youbora.lib6.plugin.Options;
import com.npaw.youbora.lib6.plugin.Plugin;

public class DemoApp extends MultiDexApplication {
	private static final String TAG = "DemoApp";

	private static final String YOUBORA_CUSTOMER_KEY = "castlabsdev";

	public Plugin youboraPlugin;

	@Override
	public void onCreate() {
		super.onCreate();

		// Enable Youbora Logging
		YouboraLog.setDebugLevel(YouboraLog.Level.VERBOSE);

		// IMA
		// Register the IMA ads plugin
		ImaPlugin imaPlugin = new ImaPlugin();
		imaPlugin.setEnabled(true);
		// Set the IMA SDK settings
		ImaSdkSettings imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings();
		imaSdkSettings.setLanguage("en");
		imaPlugin.setImaSdkSettings(imaSdkSettings);
		PlayerSDK.register(imaPlugin);

		// Enable Youbora Analytics. If you're using Youbora Sessions, you'll need to add
		// the page tracking calls yourself. The castLabs SDK will only take care of video tracking.
		// By passing the Youbora "Plugin" instance to the SDK, Youbora will link the video sessions
		// with the application session.
		Options options = new Options();
		options.setAccountCode(YOUBORA_CUSTOMER_KEY);
		this.youboraPlugin = new Plugin(options, this);

		YouboraPlugin youboraPlugin = new YouboraPlugin(YOUBORA_CUSTOMER_KEY, this.youboraPlugin);
		// In case Youbora Sessions are not to be enabled, there's no need to provide a
		// Youbora Plugin instance to the SDK
		//YouboraPlugin youboraPlugin = new YouboraPlugin(YOUBORA_CUSTOMER_KEY);

		// Optional: Report SDK warnings as Youbora non-fatal errors (default: false)
		//youboraPlugin.reportWarnings(true);
		PlayerSDK.register(youboraPlugin);

		PlayerSDK.init(getApplicationContext());
	}
}
