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: 
mkdir1995
Visitor

Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applications?

Hey all.

I could use a bit of clarification about the requirements to use Roku Scene Graph. All of the components that are going to be deprecated are here: https://blog.roku.com/developer/2017/02/01/legacy-sdk/ ... but then in the documentation it shows more functions/components that cannot be used here: https://sdkdocs.roku.com/display/sdkdoc ... pt+Support

So my question is, what is the most efficient way to go about this "conversion" of my app that uses the older SDK? For example, I understand that to replace roGridScreen I can use a rowList node class, but how do I implement the XML/BRS files to work together using an API's JSON data? Since I can't use methods like SetContentList(), setupLists(), setListNames(), I'm unable to see through the examples how to set content with JSON instead of XML data.

I've tried replacing the createObject("roGridScreen") with something like this: 
  
  m.screen = CreateObject("roSGScreen")
  m.port = CreateObject("roMessagePort")
  m.screen.setMessagePort(m.port)
  scene = m.screen.CreateScene("HomeGrid")
  m.screen.show()


and then I made a test .xml file called "HomeGrid.xml" where I set it up like so, just to see if it'll link together:
<?xml version="1.0" encoding="utf-8" ?> 
<component name="HomeGrid" extends="Scene" >
' stuff goes here
</component>


but I got an error saying "BRIGHTSCRIPT: ERROR: roSGScreen.CreateScene: No such node HomeGrid."

Beyond that, I'm just not sure how I change my files/structure so that all of the 40 or so files I have can work with the Roku Scene graph. What goes inside the .xml file?
The documentation and examples are somewhat helpful, but I can't figure out how to tie it in with what I already have without essentially re-doing my whole application from scratch. I have tons of functions that make requests, responses, general functions. Any help would be appreciated. 😞 
0 Kudos
13 REPLIES 13
tim_beynart
Channel Surfer

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

I'm in the same boat, and I suggest you redo all the UI from scratch. I decided that's the path of least resistance.
For content, the trick is to extend the ContentNode to include all your custom fields, then apply your array of content nodes to a List. You will probably be able to re-use the bulk of your JSON data parser. I found the requirements a little bit confusing, because the List elements require a structure of ContentNodes that is very specific, and it doesn't work right until you hit the right construct. You don't just simply load an array of elements like you did with a PosterScreen.
0 Kudos
mkdir1995
Visitor

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

"tim_beynart" wrote:
I'm in the same boat, and I suggest you redo all the UI from scratch. I decided that's the path of least resistance.
For content, the trick is to extend the ContentNode to include all your custom fields, then apply your array of content nodes to a List. You will probably be able to re-use the bulk of your JSON data parser. I found the requirements a little bit confusing, because the List elements require a structure of ContentNodes that is very specific, and it doesn't work right until you hit the right construct. You don't just simply load an array of elements like you did with a PosterScreen.

Hmm, have you looked at the videoplayer example? From all the examples I've seen, this one looks the most like what I already have. https://github.com/rokudev/videoplayer-channel 
If you don't mind, would I be able to see an example of what you're talking about? It's still a bit fuzzy to me. Thank you!
0 Kudos
tim_beynart
Channel Surfer

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

This may not be the info you are looking for, I'm not sure I read your question right. For your content feed, it looks like the parseLeaf() function (in UriHandler.brs) in that demo is what you need to modify
https://github.com/rokudev/videoplayer-channel/blob/master/components/UriHandler.brs
instead of contentNode= CreateObject("roSGNode","ContentNode"), you would use a custom component that extends ContentNode, like contentNode= CreateObject("roSGNode","MyExtendedContentNode")
and define the custom node like this, in an XML file called MyExtendedContentNode.xml

<?xml version="1.0" encoding="utf-8" ?>
<component name="MyExtendedContentNode" extends="ContentNode">
<interface>
  <field id="thumbnail" type="string" />
  <field id="contentType" type="string" />
  <field id="title" type="string" />
  <field id="entitlement" type="string" />
  <field id="externalAdvertiserId" type="string" />
  <field id="mediaGuid" type="string" />
  <field id="accountId" type="string" />
  <field id="duration" type="float" />
  <field id="trackingData" type="assocarray" />
  <field id="category" type="string" />
</interface>
</component>

Then as you parse your JSON you can assign all the custom fields you require and the List component in SG will still honor the fundamental fields of a ContentNode.
0 Kudos
mkdir1995
Visitor

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

"tim_beynart" wrote:
This may not be the info you are looking for, I'm not sure I read your question right. For your content feed, it looks like the parseLeaf() function (in UriHandler.brs) in that demo is what you need to modify
https://github.com/rokudev/videoplayer-channel/blob/master/components/UriHandler.brs
instead of contentNode= CreateObject("roSGNode","ContentNode"), you would use a custom component that extends ContentNode, likecontentNode= CreateObject("roSGNode","MyExtendedContentNode")[/size][/font][/color]
and define the custom node like this, in an XML file called MyExtendedContentNode.xml

<?xml version="1.0" encoding="utf-8" ?>
<component name="MyExtendedContentNode" extends="ContentNode">
<interface>
  <field id="thumbnail" type="string" />
  <field id="contentType" type="string" />
  <field id="title" type="string" />
  <field id="entitlement" type="string" />
  <field id="externalAdvertiserId" type="string" />
  <field id="mediaGuid" type="string" />
  <field id="accountId" type="string" />
  <field id="duration" type="float" />
  <field id="trackingData" type="assocarray" />
  <field id="category" type="string" />
</interface>
</component>

Then as you parse your JSON you can assign all the custom fields you require and the List component in SG will still honor the fundamental fields of a ContentNode.

Hmmm... very confusing. What exactly is the size, font, color you listed? And how do those styles connect to the ContentNode? There are multiple fields (thumbnail, contentType) so these styles would apply to all of the fields?
0 Kudos
destruk
Binge Watcher

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

The size font color junk in the message is automatically entered when you copy and paste sometimes into the message box on the forum - you can ignore all that.
0 Kudos
mkdir1995
Visitor

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

"destruk" wrote:
The size font color junk in the message is automatically entered when you copy and paste sometimes into the message box on the forum - you can ignore all that.

oh thanks, destruk! but then where in that myExtendedContentNode component are all of those styles being applied?
0 Kudos
destruk
Binge Watcher

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

You'd need to add those fields to your extended content node if you want to have specific fonts, sizes, or placement associated with your content.  Or you could put those values into a separate array.  It's an open system so you can organize your data any way you like, but the existing components are easier to use if you comply with the supported content metadata and content nodes or extended content nodes.
https://sdkdocs.roku.com/display/sdkdoc/Font
0 Kudos
mkdir1995
Visitor

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

"destruk" wrote:
You'd need to add those fields to your extended content node if you want to have specific fonts, sizes, or placement associated with your content.  Or you could put those values into a separate array.  It's an open system so you can organize your data any way you like, but the existing components are easier to use if you comply with the supported content metadata and content nodes or extended content nodes.
https://sdkdocs.roku.com/display/sdkdoc/Font

I don't use any specific fonts or colors or anything with the older components. I just have my global theme styles from the roAppManager set up in a themes file and thats it. My main concern is really how MUCH do I actually have to change? Just the components that deprecate? It's all so confusing, and my app is giant with convoluted files and functions. Sigh.. 
0 Kudos
destruk
Binge Watcher

Re: Converting app with old components (roGridScreen,roPosterScreen, roSpringboardScreen etc) into Scene Graph applicati

If your current app is convoluted, then now is a good time to rewrite and streamline it.  I printed out the code for all of the last channel upgrade I did and went through with a sharpie crossing out code that wasn't used.  It saved a lot of headache.  Basically, any UI screens need to be recreated - if you used roScreen/roImageCanvas then that's a lot of work - if you used the default posterscreen or gridscreen then it's easier.  Also the video component changed so that will need to be recreated, and the springboard screen needs to be recreated, and the linking/billing routines might need to be recreated.  Take it screen by screen, take your time, get one part working and test it, and then move on to the next display.
0 Kudos