Forum Discussion

btpoole's avatar
btpoole
Channel Surfer
9 years ago

Scene Graph Understanding

Over the past couple of years this forum has provided me with much help in developing channels on Roku. I came across the Scene Graph documentation and examples and decided to take a crack at learning something new. Not sure that was a wise decision after getting into it. I came across an example for an epg done with scenes. From what I read, this particular part is no longer supported in the SDK due to copyright so was wondering if I could have somebody just explain a couple of things. The epgGridScene looked short so thought it might be easy to look into. First, from https://forums.roku.com/viewtopic.php?f ... ne#p508680 I found the code. Just wondering what the first xml file called epgGridScene.xml does exactly? The code is below:
Secondly, I see the xml file called EpgGrid.xml (shown below), provides data to be displayed on the screen. Am I correct in thinking that the main.brs executes the epgGridScene.xml which in turn gets it's data from the EpgGrid.xml? If so, would it be possible to load the content (EpgGrid.xml) from a server? If so, would I create a second entry in the epgGradScene.xml above the entry <customEPGGRID/> that would call another xml which would create a urltransfer?
If the questions seem elementary I'm sorry. I have been doing something very similar to what this seems to do but thru a lot of code, reading a server, parsing etc. Just trying to understand the benefit of using scene graph.


<?xml version="1.0" encoding="utf-8" ?> 

<!--********** Copyright 2015 Roku Corp.  All Rights Reserved. **********-->

<component name="epgGridScene" extends="Scene">

   <script type="text/brightscript" >
   
   </script>

   <children>
      <!-- EPG Grid -->
      <customEPGGrid />
   </children>
</component>



<?xml version="1.0" encoding="utf-8" ?> 

<component name="customEPGGrid" extends="EPGGrid" >

<script type="text/brightscript" >

<![CDATA[

function init()
   print "inside epg"
   m.content = createObject("RoSGNode","ContentNode")
   m.top.setFocus(true)
   
   dateNow = CreateObject("roDateTime")
   dateNow = dateNow.asSeconds() - 2000
   
   addChannel("ABC")
   addItem("ABC Show ", dateNow)
   

   addChannel("CBS")
   addItem("CBS Show ", dateNow)

   addChannel("NBC")
   addItem("NBC Show ", dateNow)
   
   
   addChannel("NICK")
   addItem("NICK Show ", dateNow)

   addChannel("OUTSIDE")
   addItem("Outside Show ", dateNow)
   
   addChannel("TEST")
   addItem("Test Show ", dateNow)

   m.top.content = m.content
   m.top.translation = [50, 300]
   m.top.numRows = 5
   m.top.duration = 10800
   m.top.nowNextMode = false
   m.top.infoGridGap = 0
   m.top.channelInfoColumnLabel = "Hello"
   
end function

sub addChannel(channelText as string)
  m.channel = m.content.createChild("ContentNode")
  m.channel.TITLE = channelText
  m.channel.HDSMALLICONURL = "http://css.boshanka.co.uk/wp-content/uploads/2015/04/icon-logo-design-small.png"
end sub
 
sub addItem(progText as string, timeStart)
  For i=0 To 5 Step 1
    program = m.channel.createChild("ContentNode")
     program.TITLE = progText + str(i)
     program.PLAYSTART = timeStart + (i * 2000)
     program.PLAYDURATION = "2000"
End For
 
end sub

]]>

</script>
</component>

1 Reply

  • TheEndless's avatar
    TheEndless
    Channel Surfer
    I'd recommend walking through the tutorial as a starting point.  That should prep you for trying to understand a more complex sample app.