Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
btpoole
Channel Surfer

No Content Being Set

Using the SimpleMarkupList example in sdk but modifying it to get list and grid content from a task. Everything seems to be in order but I am not get anything to the screen. I noticed the example was using a for loop to populate the fields in the example.  Is the loop just for demonstration purposes or do you actually have to loop thru the contentNode to set the content, if so how do you loop thru the contentnode fileds?  When I execute the code below I get no errors in the scene graph or task ports.  The task runs and from the print statement I put in the Task, the field for title is being populated. I do get the focus box where the text would be and do get the generic grid icons that were setup with the grid part of the code. I have left out the grid part as I am just trying to get the list to populate first.

Edit: If I edit the line in getMarkupListData()that sets each field from [size=85]dataItem.posterUrl =  m.simpleMarkupList.hdposterurl to [size=85]dataItem.posterUrl =  m.simpleMarkupList.content.hdposterurl[/font][/size][/font][/size]
I get a syntax error for each line that sets a field value.
SimpleMarkupScene.brs

function init()
?"IN init"
m.simpleMarkupList = m.top.findNode("SimpleMarkupList")
m.simpleMarkupGrid = m.top.findNode("SimpleMarkupGrid")
m.ContentTask = createObject("RoSGNode","InitialContentReader")
m.simpleMarkupList.content=setlist()
m.ContentTask.control = "RUN"
m.simpleMarkupList.SetFocus(true)
m.simpleMarkupList.ObserveField("itemFocused", "onFocusChanged")


Function setList()
?"IN SETLIST"
m.data = CreateObject("roSGNode", "ContentNode")
m.simpleMarkupList.content =m.ContentTask.channelcontent
data=getMarkupListData()
return data
end function

function getMarkupListData() as object
?"IN GETMARKUPLISTDATA"
    dataItem = m.data.CreateChild("SimpleListItemData")
    dataItem.posterUrl =  m.simpleMarkupList.content.hdposterurl
    dataItem.labelText =  m.simpleMarkupList.content.title
    dataItem.label2Text = m.simpleMarkupList.content.title
    return m.data
end function


ContentReader.xml
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->
<component name = "InitialContentReader" extends = "Task" >
  <interface>
    <field id = "channelcontent" type = "node" />
  </interface>
  <script type = "text/brightscript" >
    <![CDATA[
    sub init()
      m.top.functionName = "readcontent"
    end sub
    sub readcontent()
PRINT "IN TASK"
channelcontent= createObject ("RoSGNode", "ContentNode")
'//////////////////CHANNEL LIST CONTENT///////////////////////////
url="http://192.168.1.xx:xxxx/data/list.php"
readInternet = createObject("roUrlTransfer")
readInternet.setUrl(url)
jsoncontent = ParseJson(readInternet.GetToString())
for each items in jsoncontent.items
contentitem =channelcontent.createChild("ContentNode")
contentitem.hdposterurl=items.icon
contentitem.title=items.name
?contentitem.title      '//THIS IS SHOWING CONTENT
end for
m.top.channelcontent= channelcontent
?"OUT OF TASK"
end sub
]]>
  </script>

</component>
0 Kudos
2 REPLIES 2
btpoole
Channel Surfer

Re: No Content Being Set

I modifed to below code. When executed, task runs, content created but I get syntax error where dataItem fields are being set. Also noticed if I try to set the dataItem fields by using m.top.channelcontent, I get nothing.

function init()
?"IN init"
m.simpleMarkupList = m.top.findNode("SimpleMarkupList")
m.simpleMarkupGrid = m.top.findNode("SimpleMarkupGrid")
m.ContentTask = createObject("RoSGNode","InitialContentReader")
m.ContentTask.control = "RUN"
?"TASK RAN"
m.simpleMarkupList.content=getMarkupListData()
m.simpleMarkupList.SetFocus(true)
m.simpleMarkupList.ObserveField("itemFocused", "onFocusChanged")
m.simpleMarkupGrid.content = getMarkupGridData()
end function


function getMarkupListData() as object
?"IN GETMARKUPLISTDATA"
    data = CreateObject("roSGNode", "ContentNode")
    dataItem = data.CreateChild("SimpleListItemData")
    dataItem.posterUrl =  m.ContentTask.channelcontent.hdposterurl  'GET SYNTAX ERROR STARTING HERE
    dataItem.labelText = m.ContentTask.channelcontent.title
    dataItem.label2Text = m.ContentTask.channelcontent.title
    return data
end function

If I run like above I get this message in the Task port:
=================================================================
Warnings occurred while spawning thread for Task component InitialContentReader
spawning thread aborted because: channel exit or timeout waiting for render thread
=================================================================
If I comment out the dataItem setting fields, the task runs with no warnings or errors, but of course no fields are created.
0 Kudos
btpoole
Channel Surfer

Re: No Content Being Set

Odd thing, according to the example the poster field is

dataItem.posterUrl =  m.ContentTask.channelcontent.hdposterurl  'GET SYNTAX ERROR STARTING HERE

Gives errors. If I change the dataItem.posterUrl to dataItem.hdposterUrl thru out the scenes, it works.
0 Kudos