LevelPlay との連携

1. 概要

LevelPlay のインタースティシャル広告やリワード広告と AdMel SDK を併用する場合、広告の表示・終了時に AdMel の音声広告の状態を適切に制御する必要があります。

2. LevelPlay の広告表示時の処理

広告が表示される際に、AdMel のオートリフレッシュを停止し、音声広告を停止します。

using UnityEngine;
using Unity.Services.Core;

// インタースティシャル広告が表示された際の処理
void OnInterstitialAdShow()
{
    AdMelSdk.DisableAutoRefresh();
    AdMelSdk.StopAd();
}

// リワード広告が表示された際の処理
void OnRewardedAdShow()
{
    AdMelSdk.DisableAutoRefresh();
    AdMelSdk.StopAd();
}

// LevelPlay のイベントリスナー登録
IronSourceInterstitialEvents.onAdOpenedEvent += OnInterstitialAdShow;
IronSourceRewardedVideoEvents.onAdOpenedEvent += OnRewardedAdShow;

3. LevelPlay の広告終了時の処理

広告が閉じられた後に、AdMel のオートリフレッシュを再開します。


// インタースティシャル広告が閉じられた際の処理
void OnInterstitialAdClosed()
{
    AdMelSdk.EnableAutoRefresh();
}

// リワード広告が閉じられた際の処理
void OnRewardedAdClosed()
{
    AdMelSdk.EnableAutoRefresh();
}

// LevelPlay のイベントリスナー登録
IronSourceInterstitialEvents.onAdClosedEvent += OnInterstitialAdClosed;
IronSourceRewardedVideoEvents.onAdClosedEvent += OnRewardedAdClosed;

4. AdMel SDK の広告再生中にインタースティシャルをスキップ

AdMel の音声広告が再生中は、インタースティシャル広告をスキップすることを推奨します。

void TryShowInterstitial()
{
    if (!AdMelSdk.IsAdShowing())
    {
        MediationService.Instance.InterstitialAd.Show();
    }
    else
    {
        Debug.Log("AdMelの音声広告が再生中のため、インタースティシャルをスキップ");
    }
}

5. まとめ

状況 処理
LevelPlay の広告が開始 AdMelSdk.DisableAutoRefresh(); AdMelSdk.StopAd();
LevelPlay の広告が終了 AdMelSdk.EnableAutoRefresh();