Quick Help

The knowledgebase is a categorized collection of answers to frequently asked questions (FAQ) and articles. You can read articles in this category or select a subcategory that you are interested in.



 How to hardcode VAST tag in ROKU channel app

Solution

We made this documentation to explain how Roku publisher can integrate several demand partners in the app to get better results by providing more transparency to pixfuture.

This part of the code is an example of the integration of two VAST partners in Roku channel custom SDK:

Sub RAF()

    adBreak = invalid

    curPos = m.Video.position

    m.Video.control = "stop"

    adIface = Roku_Ads()

    adIface.setDebugOutput(true)

    adIface.setAdPrefs(true,2)

    playContent = true

    'render pre-roll ads

    'setup array of demands tags

     urls = {

        pixfuture: "https://vast1.pixfuture.com/www/admin/vast_api/ads.php?zone_id=334&format=vast2&ad_width=ROKU_ADS_DISPLAY_WIDTH&ad_height=ROKU_ADS_DISPLAY_HEIGHT&vpi=MP4&gdpr=ROKU_ADS_KIDS_CONTENT&gdprcs=0&ip=ROKU_ADS_EXTERNAL_IP&ua=ROKU_ADS_USER_AGENT&appname=com.roku.pixfuture&bundleid=ROKU_ADS_APP_ID&appstoreurl=https%3A%2F%2Fmy.roku.com%2Fadd%2FVK2ZDD&ifa=ROKU_ADS_TRACKING_ID&deviceos=Roku%2FDVP-9.0%20%28919.00E04142A%29&deviceosversion=DVP-9.0&devicemake=Samsung&devicemodel=ROKU_ADS_DEVICE_MODEL&cb=ROKU_ADS_CACHE_BUSTER&dnt=ROKU_ADS_LIMIT_TRACKING",

        spotx: "https://search.spotxchange.com/vast/2.0/85394?VPI[]=ROKU&VPI[]=MP4&app[bundle]=ROKU_ADS_APP_ID&device[ifa]=ROKU_ADS_TRACKING_ID&player_height=ROKU_ADS_DISPLAY_HEIGHT&player_width=ROKU_ADS_DISPLAY_WIDTH&device[devicetype]=7&device[make]=Roku&device[model]=Roku&app[name]=com.roku.pixfuture&ip_addr=ROKU_ADS_EXTERNAL_IP&device[ua]=ROKU_ADS_USER_AGENT"}

    'request each demand in order to generate adpoding

    for each url in urls

        adIface.setAdUrl(urls[url]) 'replace url

        adPods = adIface.getAds() 'getting response

        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 = adIface.showAds(adBreak)

        print playContent

    end if

    if playContent then

        m.video.visible = true

        'stop

        m.video.content.PlayStart = curPos

        m.video.control = "play"

        m.global.AdTracker = 1

        m.AdTimer.control = "start"

    end if
End Sub

We modified the Roku`s sample application “Multi-Live Channel” to make a possibility to make a call to several demands within Roku RAF API. Please see below the detailed explanation of the coding.

Changes in the code to integrate pixfuture VAST:

1.
adBreak = invalid is the required condition in SDK to make it work.

2. Creating the array of demands tags:

urls = {

        pixfuture: "https://vast1.pixfuture.com/www/admin/vast_api/ads.php?zone_id=377&format=vast2&ad_width=ROKU_ADS_DISPLAY_WIDTH&ad_height=ROKU_ADS_DISPLAY_HEIGHT&vpi=MP4&gdpr=ROKU_ADS_KIDS_CONTENT&gdprcs=0&ip=ROKU_ADS_EXTERNAL_IP&ua=ROKU_ADS_USER_AGENT&appname=com.roku.pixfuture&bundleid=ROKU_ADS_APP_ID&appstoreurl=https%3A%2F%2Fmy.roku.com%2Fadd%2FVK2ZDD&ifa=ROKU_ADS_TRACKING_ID&deviceos=Roku%2FDVP-9.0%20%28919.00E04142A%29&deviceosversion=DVP-9.0&devicemake=Samsung&devicemodel=ROKU_ADS_DEVICE_MODEL&cb=ROKU_ADS_CACHE_BUSTER&dnt=ROKU_ADS_LIMIT_TRACKING",

        spotx: "https://search.spotxchange.com/vast/2.0/85394?VPI[]=ROKU&VPI[]=MP4&app[bundle]=ROKU_ADS_APP_ID&device[ifa]=ROKU_ADS_TRACKING_ID&player_height=ROKU_ADS_DISPLAY_HEIGHT&player_width=ROKU_ADS_DISPLAY_WIDTH&device[devicetype]=7&device[make]=Roku&device[model]=Roku&app[name]=com.roku.pixfuture&ip_addr=ROKU_ADS_EXTERNAL_IP&device[ua]=ROKU_ADS_USER_AGENT"}

3. In each loop iteration request of the demand URL parameter will be replaced in API:

    for each url in urls

        adIface.setAdUrl(urls[url]) 'replace url

4. By modifying adPods sequence, you may get more than one response:

adPods = adIface.getAds() 'getting response

        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