答案 0 :(得分:3)
在当前版本的RAF(1.9.6)中,没有办法这样做。
答案 1 :(得分:2)
Nas对某个限制是正确的。如果您正在观看广告,Roku核对清单将要启用“反馈用户界面”(这是“广告1的1”)
现在,您可以创建自己的roVideoPlayer来播放广告。这需要做更多的工作......
'handle this else where (like the construct):
function main
'm._raf = Roku_Ads()
'm._raf.setDebugOutput(true)
'm._raf.setAdPrefs(false, 2)
'm._raf.setAdUrl(url)
'playAds()
end function
function playAds()
' sleep for half a second
sleep(500)
' setup some variables we'll be using
canvas = createObject("roImageCanvas")
' get the ads from the url
adPods = m._raf.getAds()
if adPods <> invalid and adPods.Count() > 0 then
' quick display for us to know how many ads we're playing
print "playing " adPods.Count() " ads"
' loop through each ad pod
for each adPod in adPods
' handle any top level logic here
' loop through each ad within the adPod now
for each ad in adPod.ads
' default ad rendering by raf: m._raf.showAds(adPods)
' start playing the ad
adVideoPlayer = playVideoContent(ad.streams)
playingAd = true
' custom event loop for the ad video player
while playingAd
videoMsg = wait(500, adVideoPlayer.getMessagePort())
if type(videoMsg) = "roVideoPlayerEvent" then
if videoMsg.isStreamStarted() then
canvas.clearLayer(2) ' clear buffering layer
canvas.setLayer(1, [{ color: "#00000000", CompositionMode: "Source" }])
canvas.show()
else if videoMsg.isPlaybackPosition() then
' loop through all trackers to see if we need to trigger any of them
for each tracker in ad.tracking
' make sure its not triggered first and that the tracker has a "time" property
if not tracker.triggered and tracker.time <> invalid then
print "* ad position: " videoMsg.getIndex() " / " adVideoPlayer.getPlaybackDuration()
if (int(videoMsg.getIndex()) + 1) >= int(tracker.time) then
print "triggering ad event " tracker.event ", triggered at position " tracker.time
m._raf.fireTrackingEvents(ad, {type: tracker.event})
tracker.triggered = true
end if
end if
end for
end if
if videoMsg.isStatusMessage() then
status = videoMsg.getMessage()
if status = "startup progress" then
' handle loading bar or anything else here
else if status = "start of play" then
' we should be playing the video, nuke the buffering layer and set layer 1 to a black background
canvas.clearLayer(2) ' clear buffering layer
canvas.setLayer(1, [{ color: "#00000000", CompositionMode: "Source" }])
canvas.show()
else
print "ad status: " status
end if
' roVideoPlayer sends "end of stream" last for all exit conditions
if status = "playback stopped" or status = "end of playlist" or status = "end of stream" then
print "done playing ads"
playingAd = false
end if ' end status check
end if ' end isStatusMessage
end if ' end type(videoMsg)
end while
if type(adVideoPlayer) = "roVideoPlayer" then
print "stop the ad video player"
adVideoPlayer.stop()
end if
end for
end for
else
print "no ads to play"
end if
end function