Schedule VAST ads

Add advertising breaks to your content when using the VAST ad client in an Android app.


👍

IMPORTANT

If you are using IMA ad tags, follow the steps in Schedule Google IMA ads.

The most basic advertising implementation is to run a single VAST ad tag as a pre-roll before each playlist item.



Scheduling Ad Breaks

Add a pre-roll ad break to a player

Use the following steps to add a pre-roll ad to the player you added to your activity:

  1. In the Activity, create a List<AdBreak> object and name it, for example, adSchedule.
  2. Use AdBreak.Builder() to create an AdBreak object. At the minimum, you must pass an ad tag to the tag property.

    The ad tag can include ad pods and have custom parameters appended to the URL.

🚧

When configuring ad pods that contain both VPAID 2.0 and linear ads, it is important that you schedule the VPAID 2.0 ads for the linear ads. You cannot mix this sequence.


  1. Add the AdBreak object to adSchedule.
  2. Use VastAdvertisingConfig.Builder() to create a VastAdvertisingConfig object. Use adSchedule -- which defines the ad schedule to use -- as the argument.
  3. Use PlayerConfig.Builder() to add the VastAdvertisingConfig object to the advertisingConfig property of the PlayerConfig object. This adds the ad schedule to the player.
List<AdBreak> adSchedule = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag.xml")
        .build();

adSchedule.add(adBreak);

VastAdvertisingConfig advertisingConfig = new VastAdvertisingConfig.Builder()
        .schedule(adSchedule)
        .build();

PlaylistItem playlistItem = new PlaylistItem.Builder()
        .file("https://cdn.jwplayer.com/manifests/{MEDIA_ID}.m3u8")
        .build();

List<PlaylistItem> playlist = new ArrayList<>();
playlist.add(playlistItem);

PlayerConfig config = new PlayerConfig.Builder()
        .playlist(playlist)
        .advertisingConfig(advertisingConfig)
        .autostart(true)
        .build();

player.setup(config);

You can build upon this basic implementation by adding more ad breaks or defining ad rules.



Add multiple ad breaks to a player

Use the following steps to add multiple ad breaks to the previous VAST pre-roll example:

  1. Define an additional AdBreak object.
  2. Assign an ad tag to the tag property.
  3. When defining the offset property, choose one of the following values to schedule a mid-roll or post-roll ad:

    Mid-roll
    -{number}: (String) Ad plays after the specified number of seconds
    -{timecode}: (String) Ad plays at a specific time, in hh:mm:ss:mmm format
    -{xx%}: (String) Ad plays after xx% of the content has played

    Post-roll
    -post: (String) Ad plays after the content

  4. Add the additional AdBreak object to adSchedule.
List<AdBreak> adSchedule = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag.xml")
        .offset("pre")
        .build();

AdBreak adBreak2 = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag-mid-roll1.xml")
        .offset("10")
        .build();

AdBreak adBreak3 = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag-mid-roll2.xml")
        .offset("00:00:15:000")
        .build();

AdBreak adBreak4 = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag-mid-roll3.xml")
        .offset("25%")
        .build();

AdBreak adBreak5 = new AdBreak.Builder()
        .tag("https://www.domain.com/adtag-post-roll.xml")
        .offset("post")
        .build();

adSchedule.add(adBreak);
adSchedule.add(adBreak2);
adSchedule.add(adBreak3);
adSchedule.add(adBreak4);
adSchedule.add(adBreak5);

VastAdvertisingConfig advertisingConfig = new VastAdvertisingConfig.Builder()
        .schedule(adSchedule)
        .build();

PlaylistItem playlistItem = new PlaylistItem.Builder()
        .file("https://cdn.jwplayer.com/manifests/{MEDIA_ID}.m3u8")
        .build();

List<PlaylistItem> playlist = new ArrayList<>();
playlist.add(playlistItem);

PlayerConfig config = new PlayerConfig.Builder()
        .playlist(playlist)
        .advertisingConfig(advertisingConfig)
        .autostart(true)
        .build();

player.setup(config);

You can build on this basic implementation by defining ad rules.



Add a VMAP ad schedule

According to the IAB, "VMAP enables the content owner to define the ad breaks within their content, including the timing for each break, how many breaks are available, what type of ads and how many are allowed in each break".

Use the following steps to add a VMAP ad schedule to a player:

  1. Use VmapAdvertisingConfig.Builder() to create an VmapAdvertisingConfig object.
  2. Use PlayerConfig.Builder() to add the VmapAdvertisingConfig object to the advertisingConfig property of the PlayerConfig object. This adds the ad schedule to the player.
// Set the url to the VMAP tag
VmapAdvertisingConfig vmapAdvertising = new VmapAdvertisingConfig.Builder()
        .tag("https://playertest.longtailvideo.com/adtags/vmap2.xml")
        .build();

// Create a playlist, you'll need this to build your player config
List<PlaylistItem> playlist = new ArrayList<PlaylistItem>();

PlaylistItem playlistItem = new PlaylistItem.Builder()
        .file("https://cdn.jwplayer.com/manifests/{MEDIA_ID}.m3u8")
        .build();

PlaylistItem playlistItem2 = new PlaylistItem.Builder()
        .file("https://cdn.jwplayer.com/manifests/{MEDIA_ID2}.m3u8")
        .build();

playlist.add(playlistItem);
playlist.add(playlistItem2);

// Create your player config
PlayerConfig playerConfig = new PlayerConfig.Builder()
        .playlist(playlist)
        .advertisingConfig(vmapAdvertising)
        .build();
        
// Setup your player with the config
mPlayer.setup(playerConfig);


Unsupported Feature

The following table lists and describes the feature that is unsupported

Unsupported FeatureDescription
VPAID 1.0This mode of advertising delivers Flash creatives as the ad content. We do not support Flash playback on Android. Please make sure your ad networks do not serve these type of creatives to your mobile audience as you will lose ad opportunities.


Recipes



Did this page help you?