Schedule FreeWheel ads

Schedule ads with the FreeWheel Ad Manager ad client in an Android app.

After adding the FreeWheel Ad Manager to your app and acquiring the required items listed in the Requirements section, you can schedule FreeWheel ads in your Android app.


Requirements

Property Description Example
mediaId FreeWheel identifier of a particular media item fw_simple_tutorial_asset
networkId FreeWheel identifier of a network 42015
profileId FreeWheel identifier of a particular application environment fw_tutorial_android
sectionId FreeWheel identifier of a location where the video content plays fw_tutorial_android
serverId URL of FreeWheel ad server http://7cee0.v.fwmrm.net/

If you do not know where to find the FreeWheel account values in the table, contact your FreeWheel account representative.



Add a single ad break for all playlist items

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

  1. In app/java/MainActivity.java, define your FW account values: networkId, serverId, profileId, sectionId, and mediaId.
  2. Create a FwSettings object and name it, for example, called settings. Add your FW account settings to this object.
  3. Create a List<AdBreak> object and name it, for example, adSchedule.
  4. Create an AdBreak object and name it, for example, adBreak. At the minimum, you must pass an ad tag placeholder to the tag property and pass AdSource.FW to the source property.
  5. Add adBreak to adSchedule.
  6. Create a FwAdvertising object and name it, for example, advertising. Use settings and adSchedule as the arguments. The settings object defines the FreeWheel Ad Manager settings. The adSchedule object defines which ad schedule to use.
  7. Add advertising(advertising) to the config object of the player. This adds the ad schedule to the player.
mPlayerView = findViewById(R.id.jwplayer);

int networkId = FREEWHEEL_NETWORK_ID;
String serverId = "FREEWHEEL_SERVER_ID";
String profileId = "FREEWHEEL_PROFILE_ID";
String sectionId = "FREEWHEEL_SECTION_ID";
String mediaId = "FREEWHEEL_MEDIA_ID";
FwSettings settings = new FwSettings(networkId, serverId, profileId, sectionId, mediaId);

List<AdBreak> adSchedule = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
    .tag("fw_preroll")
    .source(AdSource.FW)
    .build();
        
adSchedule.add(adBreak);

FwAdvertising advertising = new FwAdvertising(settings, adSchedule);

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)
    .advertising(advertising)
    .build();

mPlayerView.setup(config);

You can build upon this basic implementation by adding multiple ad breaks.



Add multiple ad breaks for all playlist items

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

  1. Define an additional AdBreak object.
  2. Define the object's offset property. When defining the offset property, choose one of the following values to schedule a mid-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.

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

  3. Pass AdSource.FW to the source property.
  4. Add the additional AdBreak object to adSchedule.

In the code examples below, we have added three additional ad breaks: adBreak2, adBreak3, adBreak4.

mPlayerView = findViewById(R.id.jwplayer);

int networkId = FREEWHEEL_NETWORK_ID;
String serverId = "FREEWHEEL_SERVER_ID";
String profileId = "FREEWHEEL_PROFILE_ID";
String sectionId = "FREEWHEEL_SECTION_ID";
String mediaId = "FREEWHEEL_MEDIA_ID";
FwSettings settings = new FwSettings(networkId, serverId, profileId, sectionId, mediaId);

List<AdBreak> adSchedule = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
    .tag("fw_preroll")
    .offset("pre")
    .source(AdSource.FW)
    .build();

AdBreak adBreak2 = new AdBreak.Builder()
    .tag("fw-midroll1")
    .offset("10")
    .source(AdSource.FW)
    .build();

AdBreak adBreak3 = new AdBreak.Builder()
    .tag("fw-midroll2")
    .offset("00:00:15:000")
    .source(AdSource.FW)
    .build();

AdBreak adBreak4 = new AdBreak.Builder()
    .tag("fw-midroll3")
    .offset("25%")
    .source(AdSource.FW)
    .build();
        
adSchedule.add(adBreak);
adSchedule.add(adBreak2);
adSchedule.add(adBreak3);
adSchedule.add(adBreak4);

FwAdvertising advertising = new FwAdvertising(settings, adSchedule);

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)
    .advertising(advertising)
    .build();

mPlayerView.setup(config);



Specify ad content for a specific playlist item

Use the following steps to specify advertising content for a specific playlist item. If you do not apply these steps to a playlist item, the default FreeWheel advertising content will play.

  1. For a specific playlist item, create a PlaylistItem. In our code example, we name this object playlistItem2.
  2. Define the freewheelSettings property with the FreeWheel settings for the advertising content. This associates the specific FreeWheel advertising content to the PlaylistItem.
mPlayerView = findViewById(R.id.jwplayer);

int networkId = FREEWHEEL_NETWORK_ID;
String serverId = "FREEWHEEL_SERVER_ID";
String profileId = "FREEWHEEL_PROFILE_ID";
String sectionId = "FREEWHEEL_SECTION_ID";
String mediaId = "FREEWHEEL_MEDIA_ID";
FwSettings settings = new FwSettings(networkId, serverId, profileId, sectionId, mediaId);

List<AdBreak> adSchedule = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
    .tag("fw_preroll")
    .offset("pre")
    .source(AdSource.FW)
    .build();

AdBreak adBreak2 = new AdBreak.Builder()
    .tag("fw-midroll1")
    .offset("10")
    .source(AdSource.FW)
    .build();

AdBreak adBreak3 = new AdBreak.Builder()
    .tag("fw-midroll2")
    .offset("00:00:15:000")
    .source(AdSource.FW)
    .build();

AdBreak adBreak4 = new AdBreak.Builder()
    .tag("fw-midroll3")
    .offset("25%")
    .source(AdSource.FW)
    .build();
        
adSchedule.add(adBreak);
adSchedule.add(adBreak2);
adSchedule.add(adBreak3);
adSchedule.add(adBreak4);

FwAdvertising advertising = new FwAdvertising(settings, adSchedule);

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")
    .freewheelSettings(new FwSettings FREEWHEEL_NETWORK_ID, FREEWHEEL_SERVER_ID, FREEWHEEL_PROFILE_ID, FREEWHEEL_SECTION_ID, FREEWHEEL_MEDIA_ID) 
    .build();

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

PlayerConfig config = new PlayerConfig.Builder()
    .playlist(playlist)
    .advertising(advertising)
    .build();

mPlayerView.setup(config);


Updated 7 months ago


Schedule FreeWheel ads


Schedule ads with the FreeWheel Ad Manager ad client in an Android app.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.