繁体   English   中英

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

[英]How to show preroll and midroll ads according to adBreaks using Roku RAF?

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

我如何修改或有什么可能读取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

最好将广告服务器配置为以 VMAP 格式返回响应 - 它提供广告 pod 列表(在多个位置中断) - 大概在 URL 查询中传递adBreaks ,这样更灵活,一些广告活动有特定要求,例如“仅在 [preroll|midroll|postroll] 中运行”

或者,您可以构建自己的adPods结构,格式为 https://developer.roku.com/docs/developer-program/advertising/integrating-roku-advertising-framework.md#ad-structure

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM