adrianc1982
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2016
11:59 AM
Loop through a content node
guys, could you please give me an example how to loop through a content node?
lets say i create a regular content node, and i populate it programatically from the information in my server.
now I had a json and did a task to form the content node and got it back from my task, but now i want to loop in scenegraph thread, how could i do that?
lets say i create a regular content node, and i populate it programatically from the information in my server.
now I had a json and did a task to form the content node and got it back from my task, but now i want to loop in scenegraph thread, how could i do that?
25 REPLIES 25
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2016
01:58 PM
Re: Loop through a content node
ContentNode is designed as a "vessel" for a Roku multimedia item (one video, one audio etc). It is just a Node with extra data junk (i.e. fields) shoved into it. Use ContentNode only when
If you have a collection of e.g. videos, you should use a Node as container - or roAA, depending on threading concerns.
Be more specific - what is your case?
- a RSG component demands one or
- your data is well-described by https://sdkdocs.roku.com/display/sdkdoc/Content+Meta-Data
If you have a collection of e.g. videos, you should use a Node as container - or roAA, depending on threading concerns.
Be more specific - what is your case?
adrianc1982
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2016
04:48 PM
Re: Loop through a content node
"EnTerr" wrote:
ContentNode is designed as a "vessel" for a Roku multimedia item (one video, one audio etc). It is just a Node with extra data junk (i.e. fields) shoved into it. Use ContentNode only when
- a RSG component demands one or
- your data is well-described by https://sdkdocs.roku.com/display/sdkdoc/Content+Meta-Data
If you have a collection of e.g. videos, you should use a Node as container - or roAA, depending on threading concerns.
Be more specific - what is your case?
Thanks for answering I kept trying and got to loop through a content node. Just to complete my post and give out the answer i was looking for this..
sub setEpg()
print "setting up content"
m.channel = m.liveTvJsonReaderTask.getField("content")
i = 0
while i < m.channel.getChildCount()
print "m.channel.getChild(i)", m.channel.getChild(i)
print "m.channel.getChild(i).TITLE:", m.channel.getChild(i).TITLE
i = i + 1
end while
end sub
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2016
10:32 AM
Re: Loop through a content node
Oh, that. Then you can as well do
or more convolutedly
Word has it that in coming version of RSG you could just use a roArray-type field instead of doing this whole gallimaufry (using Node as array-alike container).
channels = m.liveTvJsonReaderTask.content.getChildren(1e4, 0)
for each channel in channels:
print channel.title, channel
next
or more convolutedly
channelNoid = m.liveTvJsonReaderTask.content
for i = 0 to channelNoid.getChildCount()-1:
channel = channelNoid.getChild(i)
print channel.title, channel
next
Word has it that in coming version of RSG you could just use a roArray-type field instead of doing this whole gallimaufry (using Node as array-alike container).
adrianc1982
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016
11:10 AM
Re: Loop through a content node
"EnTerr" wrote:
Oh, that. Then you can as well dochannels = m.liveTvJsonReaderTask.content.getChildren(1e4, 0)
for each channel in channels:
print channel.title, channel
next
or more convolutedlychannelNoid = m.liveTvJsonReaderTask.content
for i = 0 to channelNoid.getChildCount()-1:
channel = channelNoid.getChild(i)
print channel.title, channel
next
Word has it that in coming version of RSG you could just use a roArray-type field instead of doing this whole gallimaufry (using Node as array-alike container).
It would be great to have an interfase that returns roassociativearray with more roassociativearrays inside. Or just a dynamic format hahah
But yeah im using the content node as an array since thats what i found i could use..
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016
11:36 AM
Re: Loop through a content node
"adrianc1982" wrote:
It would be great to have an interfase that returns roassociativearray with more roassociativearrays inside.
You already have that, you can do roAssociativeArray of... anything, really. What you don't have is <roArray of anything>. Because... RSG creator's vision ("think different, not necessarily better"):
' you cant have this: '
myNode.addFields({ myField: [1, 2, 3] })
' however, you can cheat and do this just fine: '
myNode.addFields({ myField: {bless_RSGs_maker: [1, 2, 3]} })
Or just a dynamic format hahah
But yeah im using the content node as an array since thats what i found i could use..
Here is me struggling with the same earlier https://forums.roku.com/viewtopic.php?f=34&t=96382
adrianc1982
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016
10:41 PM
Re: Loop through a content node
"EnTerr" wrote:"adrianc1982" wrote:
It would be great to have an interfase that returns roassociativearray with more roassociativearrays inside.
You already have that, you can do roAssociativeArray of... anything, really. What you don't have is <roArray of anything>. Because... RSG creator's vision ("think different, not necessarily better"):' you cant have this: '
myNode.addFields({ myField: [1, 2, 3] })
' however, you can cheat and do this just fine: '
myNode.addFields({ myField: {bless_RSGs_maker: [1, 2, 3]} })Or just a dynamic format hahah
But yeah im using the content node as an array since thats what i found i could use..
Here is me struggling with the same earlier https://forums.roku.com/viewtopic.php?f=34&t=96382
Just read this answer before posting in your thread, im new to RSG so i havent had the chance to or flight hours to discover this. I really have always thought of roku development as hacky because of all the cheating you have to do. Thank you so much for the heads up even though this is not what we should be doing!
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2016
10:08 AM
Re: Loop through a content node
"adrianc1982" wrote:
Just read this answer before posting in your thread, im new to RSG so i havent had the chance to or flight hours to discover this. I really have always thought of roku development as hacky because of all the cheating you have to do. Thank you so much for the heads up even though this is not what we should be doing!
Correct, coding for Roku is very hacky. Some of the hacks are really beautiful and useful, others - not so much. The RSG in particular will make you wonder "man, they must sell some really strong ganja in those California pot dispensaries!"
adrianc1982
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016
01:30 AM
Re: Loop through a content node
"EnTerr" wrote:"adrianc1982" wrote:
Just read this answer before posting in your thread, im new to RSG so i havent had the chance to or flight hours to discover this. I really have always thought of roku development as hacky because of all the cheating you have to do. Thank you so much for the heads up even though this is not what we should be doing!
Correct, coding for Roku is very hacky. Some of the hacks are really beautiful and useful, others - not so much. The RSG in particular will make you wonder "man, they must sell some really strong ganja in those California pot dispensaries!"
yeah i've loved some of the hacks back in brightscript, im trying to code myself into RSG but my old channel is over 6000 lines of code, its not that easy.. heheh but im 30% done give or take. I hope i get to understand RSG more and more by the time im 100% done with my channel. I really do feel like a developer discovering all this cheats and hacks and seeing all that speed with something I shouldnt be using. Thank you for your answers its always a delight to read them and i apologize for my broken english, i try my best just to keep up with you 🙂
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016
06:35 PM
Re: Loop through a content node
"EnTerr" wrote:"adrianc1982" wrote:
It would be great to have an interfase that returns roassociativearray with more roassociativearrays inside.
You already have that, you can do roAssociativeArray of... anything, really. What you don't have is <roArray of anything>. Because... RSG creator's vision ("think different, not necessarily better"):' you cant have this: '
myNode.addFields({ myField: [1, 2, 3] })
' however, you can cheat and do this just fine: '
myNode.addFields({ myField: {bless_RSGs_maker: [1, 2, 3]} })Or just a dynamic format hahah
But yeah im using the content node as an array since thats what i found i could use..
Here is me struggling with the same earlier https://forums.roku.com/viewtopic.php?f=34&t=96382
En Terr
I do believe I understand the myNode.addFields({ myField: {bless_RSGs_maker: [1, 2, 3]} }) but I am having some trouble. Just before my Task finish up, I have the following
Content = CreateObject("roSGNode", "ContentNode")
for each item in result
?item
data=Content.createChild("ContentNode")
data.addfields({"resultfield": {info: [item]}})
end for
?data
m.top.content=Content
I may not understand as much as I think, I know my loop above creates roassociativearray with all the info in the result. The ?data shows all teh resultfields as being roassociativearray. When I get back into the bs code, I am using something like
data=m.ContentTaskp.getChildren(1e4, 0)
for each item in data
?item
end for
Apparently I am missing a step, if I type(data) it shows to be roArray but all empty. Can you point out the missing step. Thanks for any help