Video Interstitial

Video interstitials are full-screen visuals that appear inside your application.

1. Override TMAdListener

Next, you will need to override the TMAdListener class to receive callbacks on video adverts. Create a new file and implement it like so:

public class VideoListener extends TMAdListener {

    @Override
    public void didLoad() {
        // Ready to display the video
    }

}

2. Load the video

To load a video, we recommend you load them once the Tapdaq SDK has initialised.

Go back to the TapdaqInitListener you created in the Quickstart guide, and add a call to load the video, like so:

public class TapdaqInitListener extends TMInitListener {

    @Override
    public void didInitialise() {
        super.didInitialise();
        // Ads may now be requested
        Tapdaq.getInstance().loadVideo(<CurrentActivity>,  "my_video_tag", new VideoListener());
    }

}

3. Show the video

Update your VideoListener class you created earlier to display a video:

public class VideoListener extends TMAdListener {

    @Override
    public void didLoad() {
        // Ready to display the interstitial
        Tapdaq.getInstance().showVideo(<CurrentActivity>, "my_video_tag", new VideoListener());
    }

}

The code above is executed when the video has successfully loaded. For a full list of video listeners we support, see our Callbacks page.

It is also possible to check the video is loaded before displaying it to the user, as shown below:

if (Tapdaq.getInstance().isVideoReady(<CurrentActivity>, "my_video_tag")) {
    Tapdaq.getInstance().showVideo(<CurrentActivity>, "my_video_tag", new VideoListener());
}

Build and run your application to test the advert displays correctly.

4. Load another video on close

If you wish to load another video after you have shown one, implement one of the following options:

A. Auto Reload all Ads

To auto reload all ads using the same placement tag set the global config before initialising, like so:

TapdaqConfig config = new TapdaqConfig();
config.setAutoReloadAds(true);

B. Implement Override

When creating an ad listener, create a custom constructor and store the placement tag, then override didClose() and call load for the same type and placement tag.

private class AdListener extends TMAdListener {
        private String mTag;

        AdListener(String tag) {
            mTag = tag;
        }

        @Override
        public void didClose() {
            Tapdaq.getInstance().loadVideo(<CurrentActivity>, mTag, this);
        }
    }

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.

What's next?

Now that you have successfully integrated a video into your app, what would you like to do next?