Ads

In order to show ads you need to configure the player to do so. There are two alternatives: Either configure them in the platform or configure them manually for the player.

Configure ads in the platform

If FPFlowplayer was provided with a valid FPFlowplayerMedia then a Flowplayer config will be fetched and all the ads that are included in this config will automatically play at their specified time offsets.

Configure ads manually

If you wish to use FPFlowplayer with an FPExternalMedia then you need to add ads manually. You will need to create a FPAdSchedule and pass the latter as an argument in the constructor of your FPExternalMedia.

There are two ways to create an FPAdSchedule - either by using a VMAP file or defining ad breaks by hand.

Using VMAP

Create an FPAdSchedule with a URL to an ad playlist, such as VMAP

Example

let adSchedule = FPAdSchedule(adScheduleUrl: "https://link.to.a.vmap.file")
let externalMedia = FPExternalMedia(mediaUrl: URL(string: "https://link.to.a.media.file")!, adSchedule: adSchedule)

Defining ad breaks manually

Create a FPAdSchedule with a list of FPAdBreak objects, where each FPAdBreak consists of one or more ad tag URLs (such as VAST) and an offset which 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 which starts 15 seconds into the playback,
  • a post-roll break with a single ad.

Example

let preRollBreak = FPAdBreak(adTag: "https://link.to.a.vast.file", roll: .pre)
let postRollBreak = FPAdBreak(adTag: "https://link.to.a.vast.file", roll: .post)

let midRolls = ["https://link.to.a.vast.file", "https://link.to.a.vast.file"]
let midRollBreak = FPAdBreak(adTags: midRolls, offset: 15)

let adSchedule = FPAdSchedule(
    adScheduleWaterfall: [preRollBreak, midRollBreak, postRollBreak]
)

let externalMedia = FPExternalMedia(
    mediaUrl: URL(string: "https://link.to.a.media.file")!,
    adSchedule: adSchedule
)
By using this website you agree to our privacy policy
Results