kvanderwende
7 years agoVisitor
roUrlTransfer on Item Select
I have downloaded samples and searched the forum and I am having trouble getting something to work. My situation is this. I have a database that returns JSON for a grid screen. I have functions to use roUrlTransfer to retrieve the data. The grid is shows (podcasts). Each show has 1 or more seasons with episodes. I don't want to load anything until it is needed. So the grid just displays the shows. When one is selected I want to retrieve the seasons and episodes for that show.
My home scene works fine because I am getting the items for the grid during init. I understand that I cannot use roUrlTranfer from a render node. I tried following an example using Task but when the task is initialized I don't have a selected item so there is nothing to return. I tried running the task when the item is selected but I still get an error that says "BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER thread".
XML
BRS
I am not sure how to get that to work. I followed the Simple Task example and I only ever see it hit getContent one time.
If I set showIndex when the item is selected getContent never fires. I think I am not fully grasping how Tasks work.
My home scene works fine because I am getting the items for the grid during init. I understand that I cannot use roUrlTranfer from a render node. I tried following an example using Task but when the task is initialized I don't have a selected item so there is nothing to return. I tried running the task when the item is selected but I still get an error that says "BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER thread".
XML
<component name="ShowTask" extends="Task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<interface>
<field id="showIndex" type="int" value="0"/>
<field id="showContentAA" type="assocarray"/>
</interface>
<script type="text/brightscript" uri="pkg:/components/Tasks/ShowTask.brs" />
</component>
BRS
sub init()
m.top.functionName = "getContent"
end sub
function getContent() as void
print "getContnent"
if m.top.showIndex <> invalid
m.top.showContentAA = getShowLeaves(m.top.showIndex)
end if
end function
I am not sure how to get that to work. I followed the Simple Task example and I only ever see it hit getContent one time.
m.showTask = CreateObject("roSGNode", "SimpleTask")
m.showTask.ObserveField("showIndex", "onIndexChanged")
m.showTask.control = "RUN"
If I set showIndex when the item is selected getContent never fires. I think I am not fully grasping how Tasks work.