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: 
abdeee_
Visitor

How to add Ads in the adpod from two different APIs?

Hi All,

I am trying to find the solution for showing the Ads from two different APIs, which is to be added in a single adpod.

Any help or source code would be appreciated 🙂
0 Kudos
4 REPLIES 4
NB_
Roku Guru

Re: How to add Ads in the adpod from two different APIs?

You can do that, see the ad structure that can be used to RAF.importAds()
https://sdkdocs.roku.com/display/sdkdoc ... dStructure

It's an array of ad pods. Where each pod is AA with `ads` being an array of ads. You can simply do
myAdPod.ads.append(newAd)
myAdPod.duration += newAd.duration

something like that
0 Kudos
abdeee_
Visitor

Re: How to add Ads in the adpod from two different APIs?

adIface = Roku_Ads()
    url = ""
    m.adIface.setAdUrl(url)
    
    adPods = m.adIface.getAds()
    if adPods <> invalid and adPods.Count() > 0
       shouldPlayContent = m.adIface.showAds(adPods)
   end if[/color]

^Code snippet is somewhat like this, In case of passing Array of URLs (Two different URLs) I am getting an exception
Can you suggest the changes?
0 Kudos
abdeee_
Visitor

Re: How to add Ads in the adpod from two different APIs?

Actually, I was able to play 3 ads using 3 different URL in sequence. but I want to show the adPods count 1 of 3, 2 of 3 and 3 of 3. currently it shows 1 of 1 for each ad.
0 Kudos
NB_
Roku Guru

Re: How to add Ads in the adpod from two different APIs?

something like this? (typed, not tried)

adBreak = invalid
for each url in urls
   raf.setAdUrl(url)
   adPods = raf.getAds()
   if adPods <> invalid and adPods.Count() > 0
       if adBreak = invalid
           adBreak = adPods
       else ' assuming VAST, only 1 pod '
           adBreak[0].ads.append(adPods[0].ads)
           adBreak[0].duration += adPods[0].duration
       end if
   end if
next
if adBreak <> invalid
  shouldPlayContent = raf.showAds(adBreak)
end if
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.