Your Digital Media Has Never Looked So Good

 
abdeee_
Topic Author
Posts: 3
Joined: Thu Nov 01, 2018 2:35 am

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

Thu Nov 01, 2018 2:54 am

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 :)
 
User avatar
RokuNB
Posts: 446
Joined: Fri Mar 31, 2017 2:22 pm

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

Thu Nov 01, 2018 1:52 pm

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
 
abdeee_
Topic Author
Posts: 3
Joined: Thu Nov 01, 2018 2:35 am

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

Thu Nov 01, 2018 11:31 pm

    m.[color=#9cdcfe]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?
 
abdeee_
Topic Author
Posts: 3
Joined: Thu Nov 01, 2018 2:35 am

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

Fri Nov 02, 2018 12:19 am

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.
 
User avatar
RokuNB
Posts: 446
Joined: Fri Mar 31, 2017 2:22 pm

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

Fri Nov 02, 2018 2:29 pm

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

Who is online

Users browsing this forum: No registered users and 2 guests