Need confirmation/information from anyone whether we can
"Integrate ads in Scene Graph Complements instead of Bright Script?"The example shared in Roku Documentation covers only integrating ads in Brightscript Main Thread:
https://sdkdocs.roku.com/display/sdkdoc ... leChannelshttps://sdkdocs.roku.com/download/attac ... 119&api=v2I figured that
showAds() cannot be used inside Screen Graph Rendered Thread or Task Node Thread as I have observed error in both the scenarios:roImageCanvas: class PLUGIN on thread RENDER|MARKUP: roku_ads_lib:/Roku_Ads.brs(2614)Below mentioned is the code of the Sample Application - appMain.brs, VideoScene.xml and AdTask.xml:
Sub Main()
playVideo()
End Sub
Function playVideo()
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("videobannerScene")
screen.show()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
exit while
endif
endif
end while
End Function
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2015 Roku Corp. All Rights Reserved. **********-->
<component name="videobannerScene" extends="Scene" >
<script type="text/brightscript" >
<![CDATA[
sub init()
initializeTask()
setVideo()
end sub
function initializeTask()
m.adTask = CreateObject("roSGNode", "AdTask")
m.adTask.control = "RUN"
end function
function setVideo() as void
videoContent = createObject("RoSGNode", "ContentNode")
videoContent.url = "https://roku.s.cpl.delvenetworks.com/media/59021fabe3b645968e382ac726cd6c7b/60b4a471ffb74809beb2f7d5a15b3193/roku_ep_111_segment_1_final-cc_mix_033015-a7ec8a288c4bcec001c118181c668de321108861.m3u8"
videoContent.title = "Closed Captions in Scene Graph"
videoContent.streamformat = "hls"
m.video = m.top.findNode("musicvideos")
m.video.content = videoContent
m.video.notificationinterval = 1
m.video.setFocus(true)
m.video.control = "play"
end function
]]>
</script>
<children>
<Video id="musicvideos" width="1280" height="720" translation="[0,0]" />
</children>
</component>
<?xml version="1.0" encoding="utf-8" ?>
<component name="AdTask" extends="Task" >
<script type="text/brightscript" >
<![CDATA[
Library "Roku_Ads.brs"
sub init()
m.top.functionName = "initAds"
end sub
function initAds()
adIface = Roku_Ads()
adUrl = "file://pkg:/images/ads.xml"
adIface.setAdUrl(adUrl)
ads = adIface.getAds()
if ads <> invalid and ads.count() > 0
For Each adPod In ads
if adPod["rendersequence"] = "preroll"
adIface.showAds(ads)
end if
End For
end if
end function
]]>
</script>
</component>
FYI: I am able view traces of Brightscript Main Thread in 8085, Render Scene Graph Thread in 8089 and Task Node Thread in 8090 as mentioned in the post:
https://sdkdocs.roku.com/display/sdkdoc ... plications