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: 
Dhir_Pratap
Streaming Star

Populate a LabelList from server data using Scene Graph

I'm trying to do samples with Scene Graph XML. Currently I would like to display content in a LabelList with server data. Can someone point me towards samples on how to achieve this. I'm very new to the platform and the the official documents does not seem to provide a complete example to do this.
Lets say I am using http://www.sdktestinglab.com/homeoptionslistcontent.xml to get the data.
I'm using the snippet given here https://sdkdocs.roku.com/display/sdkdoc/Downloading+Server+Content#DownloadingServerContent-Configur... as a starting point. Please help
0 Kudos
9 REPLIES 9
RokuJoel
Binge Watcher

Re: Populate a LabelList from server data using Scene Graph

Hi, what is missing or what would you like to see in the example that would be helpful?

- Joel
0 Kudos
Dhir_Pratap
Streaming Star

Re: Populate a LabelList from server data using Scene Graph

Hi Joel,

I would like to see the data in homeoptionslistcontent.xml inside a LabelList. I think I'm able to parse the data but the data is not Populating in to the LabelList after parsing.

Following is the code to fetch data

sub getContent()
print "In content"
content = createObject("RoSGNode","ContentNode")
contentxml = createObject("roXMLElement")

readInternet = createObject("roUrlTransfer")
readInternet.setUrl(m.top.uri)
contentxml.parse(readInternet.GetToString())
'contentxml.parse(ReadAsciiFile(m.top.uri))

itemCount = 0
if contentxml.getName()="listcontent"
for each item in contentxml.GetNamedElements("item")
attributes = item.getAttributes()
item = {
text: attributes.text
}
listitem = content.createChild("ContentNode")
listitem.title = item.text

itemCount = itemCount+1
end for
end if
m.top.content = content
print itemCount
end sub

Following is the code to populate the list.

sub showhomeoptionslist()
print "Showing List"
m.moviemenu = m.top.findNode("moviemenu")
m.moviemenu.content = m.top.content
m.moviemenu.visible=true
m.moviemenu.setFocus(true)
end sub


The logs are printed correctly. But the Label list is blank even after setting content
0 Kudos
NewManLiving
Visitor

Re: Populate a LabelList from server data using Scene Graph

You should look at the task node. There are certain objects that can be used only inside a task. roUrlTransfer is one of them. https://sdkdocs.roku.com/plugins/servle ... ew/1608450
It is also a good idea to check return codes. Anything can happen.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
Dhir_Pratap
Streaming Star

Re: Populate a LabelList from server data using Scene Graph

NewManLiving, I'm using the code to fetch data inside Task component. And the callback method specified in XML also gets called properly after completion. But the LabelList is not populated with the fetched data which is m.top.content. Something is going wrong at m.movie.content = m.top.content in callback. Do I need to do anything to refresh the view after setting the content? I am not getting any error as such which will tell me what's wrong. Can I log what is inside content? How do i do that? I really wish to have a complete sample on how to do such operation with Scene Graph and Task Node.
0 Kudos
NewManLiving
Visitor

Re: Populate a LabelList from server data using Scene Graph

Since each task node runs on its own thread you need to open telnet sessions using ports specified in the docs. They do not use the main thread on which the debugger resides. You can use print statements and they can display what is in content. I try to avoid XML as much as possible and do everything using brightscript. So my XML files usually contain a skeleton component , to which I use to add child nodes externally to the parent scene node and/or it its children. Scene Graph is still quite immature in my opinion. I dabble with it but so far I am disappointed with the documentation, lack of visual painter and the overall inability to do what it is supposed to without time consuming trial and error. Besides I have spent my entire time using the 2D and have developed an extensive framework with all the components and more that scene graph offers, including the panels. So I am not bound by the limitations of SDK 1 top level components. The only thing that attracts me to scene graph is the threads and its marketability (if there is one). So far people seem pretty frustrated with it. It would have been better to have a nice C++ library (NDK). Apart from the SDK the NDK would be my choice. So like many others I try to keep up with it but I am not sure that it is the panacea that it's hyped up to be
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
NewManLiving
Visitor

Re: Populate a LabelList from server data using Scene Graph

One more thing. Optimization for scene graph is different due to threads. If memory serves me correctly there are differences in passing/assigning by value or reference. I believe that some of the larger data structures such as an AA may be copied instead of referenced. So the whole thing can really get complex and become a drag on the lower models. The docs and the examples are the first place improvements need to be made.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
Dhir_Pratap
Streaming Star

Re: Populate a LabelList from server data using Scene Graph

Thank you so much for your thoughts NML. I am also having hard time shuffling through the docs, for something I thought is very basic task. At this point I can not invest much time in creating 2D components hence I thought scene graph would be good start. BTW I was able to set the data to PosterGrid after parsing the response in Task node. But LabelList is still a problem. I had to do the following change


'content is interface feild
m.moviemenu.content = m.readPosterGridTask.getField("content")
0 Kudos
haridhanani
Visitor

Re: Populate a LabelList from server data using Scene Graph

is it possible to get full example for populate server data???
0 Kudos
xavier
Visitor

Re: Populate a LabelList from server data using Scene Graph

"NewManLiving" wrote:
Since each task node runs on its own thread you need to open telnet sessions using ports specified in the docs. They do not use the main thread on which the debugger resides. You can use print statements and they can display what is in content. I try to avoid XML as much as possible and do everything using brightscript. So my XML files usually contain a skeleton component , to which I use to add child nodes externally to the parent scene node and/or it its children. Scene Graph is still quite immature in my opinion. I dabble with it but so far I am disappointed with the documentation, lack of visual painter and the overall inability to do what it is supposed to without time consuming trial and error. Besides I have spent my entire time using the 2D and have developed an extensive framework with all the components and more that scene graph offers, including the panels. So I am not bound by the limitations of SDK 1 top level components.  The only thing that attracts me to scene graph is the threads and its marketability (if there is one). So far people seem pretty frustrated with it. It would have been better to have a nice C++ library (NDK). Apart from the SDK the NDK would be my choice. So like many others I try to keep up with it but I am not sure that it is the panacea that it's hyped up to be

Hi @NewManLiving, I am implemeting a Scenegraph type of channel but I am hitting performance issue while starting the channel since all my screens are init one shot...The idea to add child to Scene component afterward since a great work around regarding performance concern. Any hint how to do this ? Thanks
0 Kudos