Advertisements
When you use the Wowza Flowplayer in you Android applications, you can incorporate advertisements to monetize content and engage your viewers.
The Android SDK supports IMA3-based Video Ad Serving Template (VAST) and Video Multiple Ad Playlist (VMAP) ad integrations. It also accommodates popular third-party software-building tools like Google's Interactive Media Ads (IMA) SDK. With these technologies, you can customize your viewer's ad experiences and manage ad schedules and breaks within the player.
For more information about listening to ad events and handling advertising errors, see the following pages:
You can also see our demo application for ad-related examples.
Configure advertisements
The ExternalMedia class helps to load a video using a local or remote URL. When you prepare your player and define how it loads media files, you can configure how to insert advertisements into your video. You have two options to accomplish this goal:
-
Use an external VMAP file
with the
adScheduleUrl
property of theExternalMedia
class -
Create ad breaks manually
with the
adScheduleWaterfall
property of theExternalMedia
class
Use an external VMAP file
When using the ExternalMedia
class, you can include a URL to an ad playlist file such as VMAP. The VMAP specification includes an XML template that describes how to insert multiple video ads during a video.
The following example shows how to integrate the ad schedule using the adScheduleUrl
property. Make sure that the provided link points to a valid playlist file.
val externalMedia = ExternalMedia("https://link.to.a.media.file", "https://link.to.a.vmap.file")
Create ad breaks manually
When using the ExternalMedia
class, you can manually provide a list of ad breaks by leveraging the AdBreak class. If you create an ExternalMedia
instance with a list of AdBreak
objects, each AdBreak
consists of one or more ad tag URLs (such as VAST), as well as an offset that indicates the time when the break should start.
The following example creates an ad schedule that consists of:
- A pre-roll break with a single ad.
- A mid-roll break with three ads that starts 15 seconds into the playback.
- A post-roll break with a single ad.
// Pass the adTags property as a parameter for the VAST URL
// Pass the roll property as a parameter to define as pre-roll or post-roll
val preRollBreak = AdBreak("https://link.to.a.vast.file", AdBreak.Roll.PRE)
// Define an ad break array and offset to indicate when the break should start
val midRolls = arrayListOf("https://link.to.a.vast.file", "https://link.to.a.vast.file", "https://link.to.a.vast.file")
val midRollBreak = AdBreak(midRolls, 15)
val postRollBreak = AdBreak("https://link.to.a.vast.file", AdBreak.Roll.POST)
val adSchedule = arrayListOf(preRollBreak, midRollBreak, postRollBreak)
val externalMedia = ExternalMedia("https://url.to.a.media.file", adSchedule)
info
Ad breaks marked as Roll.PRE
or Roll.POST
can only contain one ad. In order to have multiple ads during an ad break, an offset needs to be passed.