Your Digital Media Has Never Looked So Good

 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 5:49 am

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. :( 
 
tim_beynart
Posts: 150
Joined: Wed Jul 15, 2015 8:30 am

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

Wed May 17, 2017 7:23 am

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.
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 7:27 am

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!
 
tim_beynart
Posts: 150
Joined: Wed Jul 15, 2015 8:30 am

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

Wed May 17, 2017 8:54 am

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.
Last edited by tim_beynart on Wed May 17, 2017 11:26 am, edited 1 time in total.
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 9:15 am

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, like [color=#24292e][size=85][font=SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace]contentNode= 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?
 
User avatar
destruk
Posts: 2487
Joined: Sat Dec 18, 2010 4:58 pm

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

Wed May 17, 2017 10:36 am

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.
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 10:38 am

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?
 
User avatar
destruk
Posts: 2487
Joined: Sat Dec 18, 2010 4:58 pm

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

Wed May 17, 2017 10:41 am

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
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 10:46 am

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.. 
 
User avatar
destruk
Posts: 2487
Joined: Sat Dec 18, 2010 4:58 pm

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

Wed May 17, 2017 11:24 am

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.
 
tim_beynart
Posts: 150
Joined: Wed Jul 15, 2015 8:30 am

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

Wed May 17, 2017 11:27 am

dang sorry about that formatting stuff, posting to this forum is beyond my capabilities.
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Wed May 17, 2017 11:35 am

destruk wrote:
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.

Not convoluted in a bad way, but there's just a lot going on, tons of functions and requests that can't be erased, but yeah... I definitely have to take it one screen at a time. There is aloooot thats going to be different. All of my screens are split into their own files and have their own createObject instances for the grid, poster, detail screen, video screen etc. And each of these files have functions used in them from OTHER .brs files. How does this get affected by the Scene Graph stuff? Did tons of research, can barely find anything.
I thought I could have multiple instances of roSGScreen, but it seems like one is enough and I have to do fancy things to incorporate the other screens. Several questions:

1) are there ANY good examples/documentation on how this works with an API/JSON!? I can't seem to find it anywhere...everything I find is mostly with an XML feed or hard-coded. @tim_beynart's explanation is about as close to any example I've got, and I still don't understand how it ties in with the response files and the visual screens.

2) I keep getting an error "BRIGHTSCRIPT: ERROR: No such node". Even when I erase all extra code and keep 2 simple files, I can't even get one SG Screen to work. Also can't find any info about this error on the forums or online :(

This is no easy feat...
 
tim_beynart
Posts: 150
Joined: Wed Jul 15, 2015 8:30 am

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

Wed May 17, 2017 12:53 pm

For JSON parsing, here's some code I threw on GitHub. It's not a complete application, don't have time right now for that, but hopefully this helps.
https://gist.github.com/timbeynart-nbcu ... 8c104f82af
 
mkdir1995
Topic Author
Posts: 12
Joined: Tue Feb 14, 2017 10:15 am

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

Thu May 18, 2017 7:40 am

tim_beynart wrote:
For JSON parsing, here's some code I threw on GitHub. It's not a complete application, don't have time right now for that, but hopefully this helps.
https://gist.github.com/timbeynart-nbcu ... 8c104f82af

Thank you!!!

Who is online

Users browsing this forum: No registered users and 3 guests