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: 

Roku ad Framework For Each error vast response

Hi,
I am trying to play a pre-roll video ad using Roku ad Framework, but am getting an error in the console, though the ad is played.
When trying to execute the following code in isolate environment I get the following error:


adIface = Roku_Ads()
vastURL = "my valid vast URL"
adIface.setAdUrl(vastURL)
adPods = adIface.getAds()
print "adPods are ",adPods

for each key in adPods
print " " key
end for

for each key in adPods
print " " adPods[key]
end for

Attempt to use a non-numeric array index not allowed at print " " adPods[key]

and when I try to show ads, I get the following error:

adIface.showAds(adPods)

BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: roku_ads_lib:/Roku_Ads.brs(2729)

I followed everything said in the RAF. Am I doing something wrong ?
0 Kudos
1 REPLY 1
EnTerr
Roku Guru

Re: Roku ad Framework For Each error vast response

"bathejasumeet" wrote:

... Attempt to use a non-numeric array index not allowed at print " " adPods[key]

adPods is an array of dictionaries. Try

for each apod in adPods
for each key in apod
print key, apod[key]
end for
print "--------------"
end for


BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: roku_ads_lib:/Roku_Ads.brs(2729)

I followed everything said in the RAF. Am I doing something wrong ?

Here you fell victim to design. Check with RokuKC for alternative wording 8-)
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.