微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 Roku RAF 根据 adBreaks 显示前贴片和插播广告?

如何解决如何使用 Roku RAF 根据 adBreaks 显示前贴片和插播广告?

我目前正在使用 Roku 广告框架 (RAF) 来展示广告。我使用示例并成功连接到 VAST 服务器,但此时我只有预贴广告。

如何修改或读取adBreaks并触发播放器在特定时刻显示广告的可能性?

sub PlayContentWithAds()
 parentNode = m.top.GetParent()
 content = m.top.content

 m.top.lastIndex = m.top.startIndex

 RAF = Roku_Ads()
 RAF.enableAdMeasurements(true)

 adServer = "https://example.adserver.com/vast.xml"

 RAF.SetAdUrl(adServer)

 keepPlay = true
 index = m.top.startIndex - 1
 itemsCount = items.Count()

 adBreaks = ["00:00:00","00:01:00","00:02:00"]

 while keepPlay
    ' check if playlist isn't complete
    if itemsCount - 1 > index
        parentNode.SetFocus(true)
        index ++
        item = items[index] ' contentNode of the video which should be played next
        RAF.SetContentId(item.id)

        if item.categories <> invalid
            RAF.SetContentGenre("Lifestyle")
        end if

        RAF.SetContentLength(int(item.length)) ' in seconds
        RAF.SetDebugOutput(false) 'for debug purpose

        adPods = RAF.GetAds() ' ads retrieving
        m.top.lastIndex = index ' save the index of last played item to navigate to appropriate detailsScreen
        csasstream = RAF.constructStitchedStream(item,adPods)
        keepPlay = RAF.renderStitchedStream(csasstream,parentNode)
    else
        keepPlay = false
    end if
 end while

end sub

解决方法

如果没记错的话,一旦您使用 RAF.GetAds() 但在 RAF.constructStitchedStream(item,adPods) 之前抓取 adPods,您可以执行以下操作:

for each adPod in adPods
 adPod.renderSequence = "midroll" 
 adPod.renderTime = 5 'position where adPod/adBreak should start
end for

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。