Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ccaines
Binge Watcher

RAF - Multiple Pre Roll Ads Can it be Done??

I want to schedule multiple ads within my pre-roll ad break. Nobody has told me that this can't be done but I'm almost convinced that this is impossible using only the Roku ad library and NOT implementing the more complicated VAST xml method.

I have successfully created an adpod object that passes 2 ads to showads() using the proper ad structure as defined in the RAF documents. My solutions works with 1 ad in the adpod but creates an error when I create an adpod with 2 or more. Here is the output:

Roku_Ads Framework version 1.6
Roku_Ads_checkAllowedFeature: Parsing whitelist for ROKU_ADS_NIELSEN_ID
Roku_Ads_util_getStringFromUrl: requesting URL: http://pubads.g.doubleclick.net/gampad/ ... 4062A%2529
Roku_Ads_util_getStringFromUrl: requesting URL: http://rtr.innovid.com/r1.5706a8ed7a453 ... =268608114
Ad 1 id: 1h6n1m
Roku_Ads_util_getStringFromUrl: requesting URL: http://pubads.g.doubleclick.net/gampad/ ... 4062A%2529
Roku_Ads_util_getStringFromUrl: requesting URL: https://rtr.innovid.com/r1.57461984b812 ... =778819289
Ad 2 id: 1h46c5
<Component: roAssociativeArray> =
{
ads: <Component: roArray>
duration: 60
rendersequence: preroll
rendertime: 0
viewed: false
}
Ad count: 2
RAF 1.6; rendering preroll pod of 2 ads

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.


Current Function:
3264: ??
3265: ??
3266: ??
3267: ??
3268: ??
3269: ??
3270: ??
3271: ??
3272:* ??
3273: ??
3274: ??
3275: ??
3276: ??
Syntax Error. (runtime error &h02) in roku_ads_lib:/Roku_Ads.brs(3272)
3272: ??

Here is the code (after I set all the RAF params):

preRollAds = []
adBreakIndex = 0
x=0
id =[]
id.Push("")
thisAd = []
a = []
duration = 0
for ads = 1 to n
gettingAd = true
while gettingAd
msg = wait(0, screen.GetMessagePort())
adPods = adIface.getAds(msg)
thisAd = adPods[0].ads
if fnIsUnique(id, thisAd[0].adid)
print "Ad "+itostr(x+1)+" id: "+thisAd[0].adid
id.Push(thisAd[0].adid)
a.Push(adPods[0].ads)
duration = duration+adPods[0].duration
gettingAd = false
endif
end while
x=x+1
end for
preRollAds = {viewed : false,
renderSequence : "preroll",
duration : duration,
renderTime : 0
ads:a
}
Print(preRollAds.ads)
? "Ad count: "+itostr(preRollAds.ads.count())
adIface.showAds(preRollAds)


What am I doing wrong??
0 Kudos
6 REPLIES 6
EnTerr
Roku Guru

Re: RAF - Multiple Pre Roll Ads Can it be Done??

Check if your XML is valid, that's the only thing i can think of.

"Syntax Error. (runtime error &h02)" is a very exotic error - notice this one is a runtime error - syntax errors tend to be compile errors. Most curious! What and when is this one really, RokuKC ?
0 Kudos
ccaines
Binge Watcher

Re: RAF - Multiple Pre Roll Ads Can it be Done??

Thanks EnTerr. How can I check if the XML is valid? Is there a debugger for that? You can view the XML from ad 1 or ad 2 from the links above. Here is a cut and paste (below) of ad 1

<?xml version="1.0" encoding="UTF-8"?>
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vast.xsd" version="2.0">
<Ad id="214948109">
<Wrapper>
<AdSystem>GDFP</AdSystem>
<VASTAdTagURI><![CDATA[http://rtr.innovid.com/r1.5717d5a4b3ce01.76059343;cb=1145840923]]></VASTAdTagURI>
<Error><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=videoplayfailed]]></Error>
<Impression><![CDATA[http://pubads.g.doubleclick.net/pagead/adview?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=JyScuYMY8uk&cid=CAASEuRoxm2BLChsengE_Un6nvjhKA]]></Impression>
<Creatives>
<Creative id="105498044789" sequence="1">
<Linear>
<TrackingEvents>
<Tracking event="start"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=part2viewed&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="start"><![CDATA[http://secure-gl.imrworldwide.com/cgi-bin/m?ci=nlsnci1087&am=4&at=view&rt=banner&st=image&ca=nlsn37085&cr=crtve&pc=ROKU_ADS_APP_ID&ce=roku&r=1145840923]]></Tracking>
<Tracking event="start"><![CDATA[https://p.ads.roku.com/pixelServer/p.html?&meType=1&evType=0&deType=ROKU_ADS_DEVICE_MODEL&chID=ROKU_ADS_APP_ID&cID=492173669&pIID=214948109&crID=105498044789&deID=ROKU_ADS_TRACKING_ID&tStamp=ROKU_ADS_TIMESTAMP&extIP=ROKU_ADS_EXTERNAL_IP]]></Tracking>
<Tracking event="firstQuartile"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=videoplaytime25&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="midpoint"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=videoplaytime50&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="thirdQuartile"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=videoplaytime75&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="complete"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=videoplaytime100&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="mute"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=admute&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="unmute"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=adunmute&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="rewind"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=adrewind&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="pause"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=adpause&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="resume"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=adresume&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="fullscreen"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=adfullscreen&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="creativeView"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=vast_creativeview&ad_mt=[AD_MT]]]></Tracking>
<Tracking event="acceptInvitation"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=acceptinvitation]]></Tracking>
<Tracking event="start"><![CDATA[http://video-ad-stats.googlesyndication.com/video/client_events?event=2&web_property=ca-pub-7650175200946213&cpn=[CPN]&break_type=[BREAK_TYPE]&slot_pos=[SLOT_POS]&ad_id=[AD_ID]&ad_sys=[AD_SYS]&ad_len=[AD_LEN]&p_w=[P_W]&p_h=[P_H]&mt=[MT]&rwt=[RWT]&wt=[WT]&sdkv=[SDKV]&vol=[VOL]&content_v=[CONTENT_V]&conn=[CONN]&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]]]></Tracking>
<Tracking event="complete"><![CDATA[http://video-ad-stats.googlesyndication.com/video/client_events?event=3&web_property=ca-pub-7650175200946213&cpn=[CPN]&break_type=[BREAK_TYPE]&slot_pos=[SLOT_POS]&ad_id=[AD_ID]&ad_sys=[AD_SYS]&ad_len=[AD_LEN]&p_w=[P_W]&p_h=[P_H]&mt=[MT]&rwt=[RWT]&wt=[WT]&sdkv=[SDKV]&vol=[VOL]&content_v=[CONTENT_V]&conn=[CONN]&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]]]></Tracking>
</TrackingEvents>
<VideoClicks>
<ClickTracking id=""><![CDATA[http://video-ad-stats.googlesyndication.com/video/client_events?event=6&web_property=ca-pub-7650175200946213&cpn=[CPN]&break_type=[BREAK_TYPE]&slot_pos=[SLOT_POS]&ad_id=[AD_ID]&ad_sys=[AD_SYS]&ad_len=[AD_LEN]&p_w=[P_W]&p_h=[P_H]&mt=[MT]&rwt=[RWT]&wt=[WT]&sdkv=[SDKV]&vol=[VOL]&content_v=[CONTENT_V]&conn=[CONN]&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]]]></ClickTracking>
<ClickTracking id="GDFP"><![CDATA[http://pubads.g.doubleclick.net/pcs/click?xai=AKAOjsuN7K9bRc2M0Y0RsGgSwIlvF6fVDFpmYewuF5dit0Mn231mK_2py9vIVZln3PR8nbY4jM41JWKWZC1j2HcZ51nOr7B7ogjZvQTBLPJmEniiqpM9X3KFA9CnWC7alosz4XHwpREPbdUYCEung40kEweC9dZrga3f32dJMOit40bdYdSYT2ni7K5EZriPH4F6&sai=AMfl-YRzFQDtS0aWXYUI_YdP4mLRn_3cDw1_5jSIE86WhxwYSroeOXUHr3IMQxe-rwIUW81Ru1BV113ODa56aE_gHfqm1r8jP4NcJFY0ESK15jpr0Q&sig=Cg0ArKJSzFQ3h8wqePU7EAE&urlfix=1]]></ClickTracking>
</VideoClicks>
</Linear>
</Creative>
</Creatives>
<Extensions>
<Extension type="activeview"><CustomTracking>
<Tracking event="viewable_impression"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=viewable_impression&acvw=[VIEWABILITY]&gv=[GOOGLE_VIEWABILITY]]]></Tracking>
<Tracking event="abandon"><![CDATA[http://pubads.g.doubleclick.net/pagead/conversion/?ai=BUbwd4DVYV-KKHoWB-gOWuoGgCZ3t4pAJAAAAEAEgvfnFJTgAWPXSsYGJA2DJtoCHyKP8GrIBCHJva3UuY29tugENMTkyMHgxMDgwX3htbMgBBdoBEGh0dHA6Ly9yb2t1LmNvbS-YArzmAcACAuACAOoCFy84MjExNDI2OS9ycmFmY3MvcnIvZGV2-ALw0R6QA6wCmAPgA6gDAeAEAdIFBRCNsr9mkAYBoAYk2AcA4AcL&sigh=qMnyFiVB0F4&label=video_abandon&acvw=[VIEWABILITY]&gv=[GOOGLE_VIEWABILITY]]]></Tracking>
</CustomTracking>
</Extension>
<Extension type="geo"><Country>US</Country>
<Bandwidth>0</Bandwidth>
</Extension>
</Extensions>
</Wrapper>
</Ad>
</VAST>
0 Kudos
renojim
Community Streaming Expert

Re: RAF - Multiple Pre Roll Ads Can it be Done??

For an XML validator, I use http://www.w3schools.com/xml/xml_validator.asp

You can definitely package multiple ads in one pod. I suspect there's something wrong with your code. When I get a chance I'll look it over, but I create a new pod setting the viewed, renderSequence, and duration attributes as appropriate and then I add an array of ads to the pod.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
ccaines
Binge Watcher

Re: RAF - Multiple Pre Roll Ads Can it be Done??

Thank you for your reply.
You can definitely package multiple ads in one pod.

This gives me hope but it seems as if I have been chasing my tail for days now. How do I create the ad array that forms the proper adpod structure??

then I add an array of ads to the pod.

What is your solution? I tried...

a.Push(adPods[0].ads)
preRollAds = ads :a

it creates 2 ads in the [ads] array but I get the error. Then I tried...
a.Push(adPods[0].ads)
preRollAds = ads :a[0]

it creates 1 ad in the [ads] array and the ad renders just fine.
0 Kudos
ccaines
Binge Watcher

Re: RAF - Multiple Pre Roll Ads Can it be Done??

This code seems to work...

preRollAds = []
a = []
duration = 0
for ads = 1 to n
adPods = adIface.getAds()
thisPod = adPods[0].ads
for each ad in thisPod
a.Push(ad)
end for
end for
preRollAds = {viewed : false,
renderSequence : "preroll",
duration : duration,
renderTime : 0
ads : a
}
playContent = adIface.showAds(preRollAds)

Where n is the number of ads scheduled in the preroll. I also removed the adId check from the previous code.
0 Kudos
renojim
Community Streaming Expert

Re: RAF - Multiple Pre Roll Ads Can it be Done??

Yep, that's pretty much what I do. However, when I first started packaging multiple ads in one pod I was getting the same ad returned with successive calls to getAds() (at least 10 successive calls), so I check for duplicates and discard them. I know the ad provider was changed recently, so this may or may not still be a problem.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.