If advertisement is done playing, play the music.

I’m using an Advertisement.Show (); to display an advertisement.

When the user is finished watching the ad or skips it, begin the GetComponent ().Play ();

How can I go about doing this?


So first of all you need to set a ShowOptions variable, which will include the callback that will be executed once the ad is shown

ShowOptions options = new ShowOptions();
options.resultCallback = HandleShowResult;
Advertisement.Show("rewardedVideo", options);

And on your callback (mine is called HandleShowResult), it receives as parameter the result of the ad shown (user saw the whole ad, user skipped the ad, ad could not be loaded). In your case if you want to play the audio no matter what, just call Play() within the callback.

private void HandleShowResult(ShowResult result)
        switch (result)
            case ShowResult.Finished:
                Debug.Log("Video completed - Offer a reward to the player");

            case ShowResult.Skipped:
                Debug.LogWarning("Video was skipped - Do NOT reward the player");

            case ShowResult.Failed:
                Debug.LogError("Video failed to show");