Forum Discussion
gsarath
10 years agoVisitor
Even I am also looking for same implementation of playing Ads from Scene Graph Thread or Task Node Thread.
Can you please confirm whether we can "Integrate ads in Scene Graph Complements instead of Bright Script?", as per my analysis I have figured out that calling showAds() in either Scene Graph Thread or Task Node Thread gives the below mentioned error:
roImageCanvas: class PLUGIN on thread RENDER|MARKUP: roku_ads_lib:/Roku_Ads.brs(2614)
Even The example shared in Roku Documentation covers only integrating ads in Brightscript Main Thread:
https://sdkdocs.roku.com/display/sdkdoc ... leChannels
https://sdkdocs.roku.com/download/attac ... 119&api=v2
I am sharing the sample code of the test application for integrating the Ads in Task for reference, to check whether I am missing any integration steps.
Below mentioned is the code of the Sample Application - appMain.brs, VideoScene.xml and AdTask.xml:
I am able view traces of Brightscript Main Thread in 8085, Render Scene Graph Thread in 8089 and Task thread in 8090 as mentioned in the roku documentation:
https://sdkdocs.roku.com/display/sdkdoc ... plications
Can you please confirm whether we can "Integrate ads in Scene Graph Complements instead of Bright Script?", as per my analysis I have figured out that calling showAds() in either Scene Graph Thread or Task Node Thread gives the below mentioned error:
roImageCanvas: class PLUGIN on thread RENDER|MARKUP: roku_ads_lib:/Roku_Ads.brs(2614)
Even The example shared in Roku Documentation covers only integrating ads in Brightscript Main Thread:
https://sdkdocs.roku.com/display/sdkdoc ... leChannels
https://sdkdocs.roku.com/download/attac ... 119&api=v2
I am sharing the sample code of the test application for integrating the Ads in Task for reference, to check whether I am missing any integration steps.
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>
I am able view traces of Brightscript Main Thread in 8085, Render Scene Graph Thread in 8089 and Task thread in 8090 as mentioned in the roku documentation:
https://sdkdocs.roku.com/display/sdkdoc ... plications