<img src="https://img.shields.io/badge/iOS-V4-009727?logo=apple" style="float:left"/><br />
You can define ad rules that control how often a viewer sees ads while viewing your video content. **Ad rules can be used only while using the JWP or IMA advertising clients.**
If you are publishing playlists that consist of short-duration videos, like tutorials or product reviews, you can define `
startOn
` (the first playlist item allowing ad playback) and `frequency
` (the regularity of ads within a playlist).If you are publishing long-form content, like webinars or interviews, you can define `
startOnSeek
` (which determines if a returning visitor is served a pre-roll before resuming content playback) and `timeBetweenAds
` (which sets the minimum time that must elapse between ads playback).
You can read [Ad rules reference](🔗) to learn more about how each ad rule impacts a user's experience.
<br /> <hr />
## Implementation
Use the following steps and code samples to define ad rules for the [player you added to your view](🔗) with an [ad schedule](🔗).
Create a `
JWAdRules
` object using the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdRulesBuilder.html" target="_blank">JWAdRulesBuilder()</a>.Assign the created `
JWAdRules
` object to your <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes.html#/c:@M@JWPlayerKit@objc(cs)JWAdvertisingConfig" target="_blank">JWAdvertisingConfig</a> using either `JWAdsAdvertisingConfigBuilder()
` or <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWImaAdvertisingConfigBuilder.html" target="_blank">JWImaAdvertisingConfigBuilder()</a>.
<br /> <hr />
## Examples
### Example 1: Short-form content
The following example illustrates a short-form media item with an IMA pre-roll. The first ad plays before the first playlist item (`startOn: 1
`). Then, subsequent pre-rolls appear for every third playlist item (`frequency: 3
`), starting with the fourth playlist item.
<br />
### Example 2: Long-form content
The following example illustrates a long-form media item with multiple JWP ad breaks. The `startOnSeek
` and `timeBetweenAds
` (set to 300 seconds) ad rules have been defined.
<br />