Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Ads Video not playing

Discussion in 'Unity Ads & User Acquisition' started by DenisDobra, Jan 22, 2022.

  1. DenisDobra

    DenisDobra

    Joined:
    Apr 25, 2019
    Posts:
    5
    Hello everyone,

    I have a little problem, everything works good, ads are initialized, unity dashboard is keeping track of my ads, but yesterday ads started not to play their video. You still can watch them, skip them and everything, but their video are not playing. They start and end with a picture from the start of their video...

    What can I do?

    This is my AdManager:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class AdManager : MonoBehaviour, IUnityAdsInitializationListener
    7. {
    8.     [SerializeField] string _androidGameId;
    9.     [SerializeField] string _iOSGameId;
    10.     [SerializeField] bool _testMode = false;
    11.     private string _gameId;
    12.  
    13.     void Awake()
    14.     {
    15.         DontDestroyOnLoad(this.gameObject);
    16.  
    17.         InitializeAds();
    18.     }
    19.  
    20.     public void InitializeAds()
    21.     {
    22.         _gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
    23.             ? _iOSGameId
    24.             : _androidGameId;
    25.         Advertisement.Initialize(_gameId, _testMode, this);
    26.     }
    27.  
    28.     public void OnInitializationComplete()
    29.     {
    30.         Debug.Log("Unity Ads initialization complete.");
    31.     }
    32.  
    33.     public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    34.     {
    35.         Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    36.     }
    37. }
    38.  
    This is how I display the ads:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3. using UnityEngine.SceneManagement;
    4. using UnityEngine.UI;
    5.  
    6. public class RewardedAds : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
    7. {
    8.     [SerializeField] string _androidAdUnitId = "rewardedVideo";
    9.     [SerializeField] string _iOSAdUnitId = "rewardedVideo";
    10.     string _adUnitId;
    11.  
    12.     void Awake()
    13.     {
    14.         _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer) ?
    15.             _iOSAdUnitId :
    16.             _androidAdUnitId;
    17.     }
    18.  
    19.     private void Start()
    20.     {
    21.         LoadAd();
    22.     }
    23.  
    24.     // Load content to the Ad Unit:
    25.     public void LoadAd()
    26.     {
    27.         // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
    28.         Debug.Log("Loading Ad: " + _adUnitId);
    29.         Advertisement.Load(_adUnitId, this);
    30.     }
    31.  
    32.     // If the ad successfully loads, add a listener to the button and enable it:
    33.     public void OnUnityAdsAdLoaded(string adUnitId)
    34.     {
    35.         Debug.Log("Ad Loaded: " + adUnitId);
    36.  
    37.         if (adUnitId.Equals(_adUnitId))
    38.         {
    39.  
    40.  
    41.         }
    42.     }
    43.  
    44.     // Implement a method to execute when the user clicks the button.
    45.     public void ShowAd()
    46.     {
    47.         // Then show the ad:
    48.         Advertisement.Show(_adUnitId, this);
    49.     }
    50.  
    51.     // Implement the Show Listener's OnUnityAdsShowComplete callback method to determine if the user gets a reward:
    52.     public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    53.     {
    54.         if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
    55.         {
    56.             // Grant a reward.
    57.             // if you are in spin menu wait the ads to be loaded
    58.             Scene currentScene = SceneManager.GetActiveScene();
    59.             if (currentScene.name == "MainMenu")
    60.             {
    61.                 PlayerInfo.instance.crowns++;
    62.                 PlayerInfo.instance.SaveGame();
    63.             }
    64.  
    65.             // Load another ad:
    66.             Advertisement.Load(_adUnitId, this);
    67.         }
    68.     }
    69.  
    70.     // Implement Load and Show Listener error callbacks:
    71.     public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    72.     {
    73.         Debug.Log($"Error loading Ad Unit {adUnitId}: {error.ToString()} - {message}");
    74.         // Use the error details to determine whether to try to load another ad.
    75.     }
    76.  
    77.     public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    78.     {
    79.         Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
    80.         // Use the error details to determine whether to try to load another ad.
    81.     }
    82.  
    83.     public void OnUnityAdsShowStart(string adUnitId) { }
    84.     public void OnUnityAdsShowClick(string adUnitId) { }
    85.  
    86.     void OnDestroy()
    87.     {
    88.         // Clean up the button listeners:
    89.         //_showAdButton.onClick.RemoveAllListeners();
    90.     }
    91. }

    EDIT: Also when i turn on Ads on Service panel it stay active for 5-10 seconds and then automatically turning off.
    I have IAP Service activated too.

    EDIT2: I found that this is happening only when the player is connected to internet using WIFI connection... If player switches do mobile data internet it is working. Please help
     
    Last edited: Jan 22, 2022
  2. LIU_Hanyang96

    LIU_Hanyang96

    Unity Technologies

    Joined:
    Jul 12, 2021
    Posts:
    113
    Hi DenisDobra,

    I am sorry for your experience.
    About your load function, please make sure you call it after the initialization has been completed. Also, please make sure you show ads after loaded. Other parts of the codes look nice.

    To solve your issue, may you attach your full device logs and a recording for your app? Then, I can help you check about your issue.
    Also, may you provide your game id?
     
  3. aylin_unity3d

    aylin_unity3d

    Unity Technologies

    Joined:
    Apr 6, 2015
    Posts:
    48
    Hey
    Could you tell us the device model and OS version of your device that you are testing?
    Thanks.