public void PlayAd(Dictionary <string, object> options, string placementId)
    {
        InvokeSafelyOnUIThreadAsync(delegate
        {
            if (sdk != null && sdk.IsAdPlayable(placementId))
            {
                if (options == null)
                {
                    options = new Dictionary <string, object>();
                }

                cfg = new AdConfig();
                SetAdConfig(cfg, options);
                if (options.ContainsKey(OptionConstants.FlexCloseSec) && options[OptionConstants.FlexCloseSec] is string)
                {
                    int seconds = 0;
                    if (int.TryParse((string)options[OptionConstants.FlexCloseSec], out seconds))
                    {
                        sdk.SetFlexViewCloseTimeInSec(placementId, seconds);
                    }
                    else
                    {
                        VungleLog.Log(VungleLog.Level.Warning, VungleLog.Context.LogEvent, "PlayAd", "FlexViewCloseTime was not an integer.");
                    }
                }
                sdk.PlayAd(cfg, placementId);
            }
        });
    }
Beispiel #2
0
	public static void playAd( Dictionary<string,object> options, string placement)
	{
		if (sdk != null && sdk.IsAdPlayable(placement)) {
			cfg = new AdConfig ();
			if (options.ContainsKey("userTag") && options["userTag"] is string)
				cfg.SetUserId ((string) options["userTag"]);
			cfg.SetSoundEnabled (_isSoundEnabled);
			if (options.ContainsKey("orientation")) {
				if (options ["orientation"] is bool) {
					cfg.SetOrientation (((bool)options ["orientation"]) ? VungleSDKProxy.DisplayOrientations.Landscape : VungleSDKProxy.DisplayOrientations.AutoRotate);
				}
				if (options ["orientation"] is VungleAdOrientation) {
					cfg.SetOrientation(((VungleAdOrientation)options ["orientation"] == VungleAdOrientation.AutoRotate) ? VungleSDKProxy.DisplayOrientations.AutoRotate : VungleSDKProxy.DisplayOrientations.Landscape);
				}
			} else
				cfg.SetOrientation((_orientation == VungleAdOrientation.AutoRotate) ? VungleSDKProxy.DisplayOrientations.AutoRotate : VungleSDKProxy.DisplayOrientations.Landscape);
			if (options.ContainsKey("alertText") && options["alertText"] is string)
				cfg.SetIncentivizedDialogBody ((string) options["alertText"]);
			if (options.ContainsKey("alertTitle") && options["alertTitle"] is string)
				cfg.SetIncentivizedDialogTitle ((string) options["alertTitle"]);
			if (options.ContainsKey("closeText") && options["closeText"] is string)
				cfg.SetIncentivizedDialogCloseButton ((string) options["closeText"]);
			if (options.ContainsKey("continueText") && options["continueText"] is string)
				cfg.SetIncentivizedDialogContinueButton ((string) options["continueText"]);
			if (options.ContainsKey("backImmediately") && options["backImmediately"] is string)
				cfg.SetBackButtonImmediatelyEnabled ((bool) options["backImmediately"]);
            if (options.ContainsKey("flexCloseSec") && options["flexCloseSec"] is string) {
                int seconds = 0;
                Int32.TryParse((string)options["flexCloseSec"], out seconds);
                sdk.SetFlexViewCloseTimeInSec(placement, seconds);
            }
			sdk.PlayAd(cfg, placement);
		}
	}