-jio-start-block-type-2
-jio-style-title
Video Multiple Ad Playlists (VMAP) are used to return multiple video ads to be played during a video. It offers content owners control over the placement and timing of ads, especially when they lack control or ownership of the player.
We support 2 types of VMAP.
1.VMAP URL
Complete GETTING STARTED section and INITIALIZE SDK section before starting this section.
Giving VMAP URL from SDK to publisher which gives VMAP xml and then rest all will be manged by publisher through IMA extension.
-jio-style-title
The IAB Video Multiple Ad Playlist (VMAP) specification is an XML template that video content owners can use to describe the structure for ad inventory insertion. In order to effectively monetize video content with in-stream insertion advertising, video content owners must carefully manage the structure and use of ad inventory opportunities available within their content.
With VMAP, video content creators can define the following:
-jio-bullet-type-1
-jio-bullet-type-1
-jio-bullet-type-1
VMAP was designed to be used in conjunction with VAST and is well-suited for video content creators who have no control over the video player, but want to control the ad experience within the videos. This method of ad scheduling is supported via VAST and Google IMA plugins
-jio-style-title
Use the below code snippet to fetch VMAP URL
var adView = JioAdview()
let vmapUrl = self.adView?.getVMAPURL(vmapID: String, contentVideoDuration: String, cue: String)
Following table provides Parameter description for getVMAPURL()
API
-jio-tables
# | Parameter Name | Description of the Parameter |
---|---|---|
1 | vmapID | Get from publisher |
2 | Duration | Content Duration, for example 100,200,etc. |
3 | CuePoints | AdBreaks in seconds. for example 10,20,30, etc |
-jio-style-title
Create needs JioAdsVMAPBuilder
object and pass the preroll, midroll and postroll adspot ids by filling JioAdsVMAPInfo
var vmapInfo = JioAdsVMAPInfo()
vmapInfo.preRollAdspot = "78z5n94d"
vmapInfo.midRollAdspot = "i3p1em25"
vmapInfo.postRollAdspot = "vq96mbge"
vmapInfo.cuePoints = [30, 90] // Make sure for this pass this in array with comma separated Integer.
vmapInfo.metadata = ["chid": "1234"] // can pass metadata as dictionary format. (String:Any)
var vmap = JioAdsVMAPBuilder()
vmap?.getVmapDataFor(vmapInfo: vmapInfo, delegate: self)
cuePoints is mandatory for the Midroll.
-jio-style-title
Destroy VMAP builder object calling below method.
var vmap = JioAdsVMAPBuilder()
vmap?.destroyVMAP()
-jio-style-title
-jio-style-title
1. onVmapDataPrepared()
This method is called when SDK successfully prepared VMAP as string. Use it in IMA framework to play the ads.
func onVmapDataPrepared(vmapData: String?) {
// Notify JioAdsVMAPBuilder when preroll is played successfully by IMA by calling below method
// Refer next IMA delegate snippet
vmap?.notifyPrerollPlayed()
// Then destroy VMAP object
vmap?.destroyVMAP()
vmap = nil
}
func adsManager(_ adsManager: IMAAdsManager, didReceive event: IMAAdEvent) {
switch event.type {
case IMAAdEventType.LOADED:
vmap?.notifyPrerollPlayed()
break
default:
break
}
}
-jio-style-title
2. onVmapDataFailedToload()
This method called when SDK is failed generate VMAP.
func onVmapDataFailedToload(error: JioAdError?) {
vmap?.destroyVMAP()
vmap = nil
}
-jio-style-title
3. Fetch VMAP URL
Use following API to get VMAP url by providing Id, duration and cue strings, App can download VMAP XML data and use it playing ads.
var adView = JioAdview()
let vmapUrl = self.adView?.getVMAPURL(vmapID: String, contentVideoDuration: String, cue: String)
JioAds SDK has the capability to fetch , parse , track and render vmap documents. Below are the integration steps
-jio-style-title
vmapUrl
objectCreate a JioVmapInfo struct object that holds all data necessary to carry out vmap ad rendering task.
let jioVmapInfo = JioVmapInfo(vmapUrl:vmapUrl, adContainer: containerView, prepareThreshold:prepareThreshold, prerollId:preRollCid, midRollId:midRollCid, postRollId: postRollId ,jioAdTargetting:jioAdTargetting)
vmapId
struct object
let jioVmapInfo = JioVmapInfo(WithID: vmapId,
videoLength: vmapVideoLength,
cuePoints: vmapCuePoints,
packageName: packageName,
adContainer: containerView,
prepareThreshold: prepareThreshold,
jioAdTargetting: jioAdTargetting)
-jio-style-title
VMAP Url
JioVmapAdsLoader class will use this url to make a http request to vmap document which will be further rendered by JioVmapAdsLoader class
-jio-style-title
Ad Container
AdContainer UIView object will be used to render video ads. JioVmapAdsLoader will create a new Player Object and render ads on this uiview object
-jio-style-title
PrerollId, MidRollId, PostRollId
The following i.dentifiers will be used for downloading tracker json files and tracking video events. Every unique identifier will be freshly downloaded every 24 hours.
-jio-style-title
prepareThreshold
prepareThreshold value will download vast document and prepare player considering the threshold duration. Default threshold value is 5.
Threshold should not be less than 5. If its less than 5 then SDK will defulat it to 5
-jio-style-title
Following are the values that can be set via JioAdTargetting
-jio-tables
# | Values | Description |
---|---|---|
1 | channelId | Sets the Channel ID |
2 | channelName | Sets the Channel Name |
3 | showName | Sets the Show Name |
4 | pageCategory | Sets the Page Category |
5 | sectionCategory | Sets the Section Category |
6 | languageOfArticle | Sets the Language of the Article |
7 | language | Sets the Language |
8 | contentId | Sets the Content ID |
9 | contentTitle | Sets the Content Title |
10 | contentType | Sets the Content Type |
11 | vendor | Sets the Vendor Name |
12 | actor | Sets the Actor Name |
13 | objects | Sets the objects |
14 | isKidsProtected | Sets the Flag for Kids Protection |
15 | gender | Sets the Gender |
16 | appVersion | Sets the App Version |
17 | genre | Sets the Genre |
18 | state | Sets the State |
19 | city | Sets the City |
20 | age | Sets the age |
21 | country | Sets the country |
22 | pincode | Sets the PIN code of the location |
23 | keywords | Sets the Keywords |
24 | placementName | Sets the Placement Name |
25 | customMetaData | Sets the custom meta data |
-jio-style-title
Create an instance of JioVmapAdsLoader class by assigning a JioVmapAdsLoaderDelegate and JioVmapInfo object that you have created earlier
let jioVmapAdsLoader = JioVmapAdsLoader(delegate: self, jioVmapInfo: jioVmapInfo)
-jio-style-title
Listen to the following callbacks via JioVmapAdsLoaderDelegate
extension ViewController: JioVmapAdsLoaderDelegate {
func onJioVmapAdsLoaded() {
print("\(TAG) onJioVmapAdsLoaded")
}
}
func onJioVmapEvent(event: JioAdsFramework.AdEventType, adMeta: JioAdsFramework.AdMeta?, dict: [String : String]?) {
switch event {
case .adBreakEnded , .contentResumeRequested :
print("\(TAG) Publisher requesting to play content")
contentPlayer?.play()
case .contentPauseRequested :
print("\(TAG) Publisher requesting to pause")
contentPlayer?.pause()
case .allAdsCompleted :
SDKLog("\(TAG) Publisher should destroy Ads Loader as all ads are completed")
jioVmapAdsLoader?.destroy()
jioVmapAdsLoader = nil
case .adBreakReady:
case .adBreakStarted:
case .adStarted:
case .adFirstQuartile:
case .adMidPoint:
case .adThirdQuartile:
case .adProgress:
case .adPaused:
case .adResumed:
case .adSkipped:
case .adClicked:
case .adCompleted:
@unknown default:
}
}
func onJioVmapError(cuePoint: Int?, error: JioAdsFramework.JioAdError) {
print("\(TAG) onJioVmapError cuePoint:\(String(describing: cuePoint)) error:\(error)")
print("\(TAG) Publisher requesting to play content")
contentPlayer?.play()
}
-jio-style-title
Request for Vmap Ads using the below given API.
jioVmapAdsLoader.requestVmapAds()
Prepare your content player before requesting VMAP Ads.
-jio-style-title
Use the below api to show ad counter. SDK by default will not show ad counter to optimize ad renditions by fetching VAST and attaching media urls to the AVQueuePlayer in an asynchronous manner. To override the SDK defaults use the below given api.
jioVmapAdsLoader.shouldShowAdCounter(showAdCounter: true)
-jio-style-title
To Track mid roll and post roll ads you need to use the below given api.
let time = CMTime(seconds: 1, preferredTimescale: 10)
observerTime = contentPlayer?.addPeriodicTimeObserver(forInterval: time, queue: .main, using: {
time in
self.jioVmapAdsLoader?.updateCurrentPlayerTime(currentPlayerTime: CMTimeGetSeconds(time), totalContentDuration: self.currentMediaDuration ?? 0.0)
})
Call this api every 500 milliseconds
-jio-style-title
STEP 5 : Whenever the user seeks forward or seeks backward call the below given API so that SDK can render skipped midroll ads
jioVmapAdsLoader?.notifyCuePointMissed(playerCurrentTime: Int(sliderNewValue))
-jio-style-title
Use the below api to pause vmap ads
jioVmapAdsLoader?.pause()
-jio-style-title
Use the below api to resume vmap ads
jioVmapAdsLoader?.resume()
-jio-style-title
Following are the APIs which are supported to set metadata.
-jio-tables
# | APIs | Description |
---|---|---|
1 | setChannelId(channelId:String?) | Sets the Channel ID |
2 | setChannelName(channelName:String?) | Sets the Channel Name |
3 | setShowName(showName:String?) | Sets the Show Name |
4 | setPageCategory(pageCategory:String?) | Sets the Page Category |
5 | setSectionCategory(sectionCategory:String?) | Sets the Section Category |
6 | setLanguageOfArticle(languageOfArticle:String?) | Sets the Language of the Article |
7 | setLanguage(language:String?) | Sets the Language |
8 | setContentId(contentId:String?) | Sets the Content ID |
9 | setContentTitle(contentTitle:String?) | Sets the Content Title |
10 | setContentType(contentType:String?) | Sets the Content Type |
11 | setVendor(vendor:String?) | Sets the Vendor Name |
12 | setActor(actor:String?) | Sets the Actor Name |
13 | setObjects(objects:String?) | Sets the objects |
14 | setIsKidsProtected(isKidsProtected:Constants.KIDS_PROTECTED?) | Sets the Flag for Kids Protection |
15 | setGender(gender:Constants.GENDER?) | Sets the Gender |
16 | setAppVersion(appVersion:String?) | Sets the App Version |
17 | setGenre(genre:String?) | Sets the Genre |
18 | setState(state:String?) | Sets the State |
19 | setCity(city:String?) | Sets the City |
20 | setAge(age:String?) | Sets the age |
21 | setCountry(country:String?) | Sets the country |
22 | setPincode(pincode:String?) | Sets the PIN code of the location |
23 | setKeywords(keywords:String?) | Sets the Keywords |
24 | setPlacementName(placementName:String?) | Sets the Placement Name |
25 | setCustomMetadata(customMetadata:Map<String,String?>?) | Sets the custom meta data |
-jio-end-block-type-2