Your Digital Media Has Never Looked So Good

 
neowinston
Topic Author
Posts: 28
Joined: Thu Feb 09, 2017 6:38 am

How do I call XML code from Brightscript for a Roku Channel?

Fri Aug 11, 2017 5:53 am

I'm trying to populate a Label List using the below XML Roku Channel, Scenegraph code. I'm getting these errors: 
BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

Invoking [size=100][font=Arial, Helvetica Neue, Helvetica, sans-serif]Brightscript code:[/font][/size]
sub showChannelSGScreen()
  screen = CreateObject("roSGScreen")
  m.port = CreateObject("roMessagePort")
  screen.setMessagePort(m.port)
  scene = screen.CreateScene("LabelListExample")
  screen.show()

  while(true)
    msg = wait(0, m.port)
    msgType = type(msg)

    if msgType = "roSGScreenEvent"
      if msg.isScreenClosed() then return
    end if
  end while

end sub


[size=100][font=Arial, Helvetica Neue, Helvetica, sans-serif]XML code:[/font][/size]
<?xml version = "1.0" encoding = "utf-8" ?>

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

<component name = "LabelListExample" extends = "Group" initialFocus = "exampleLabelList" >

  <script type = "text/brightscript" >

    <![CDATA[

    sub init()
      examplerect = m.top.boundingRect()
      centerx = (1280 - examplerect.width) / 2
      centery = (720 - examplerect.height) / 2
      m.top.translation = [ centerx, centery ]
    end sub

    ]]>

  </script>

  <children >

    <LabelList id = "exampleLabelList" >

      <ContentNode role = "content" >
        <ContentNode title = "Renderable Nodes" />
        <ContentNode title = "Z-Order/Parent-Child" />
        <ContentNode title = "Animations" />
        <ContentNode title = "Events and Observers" />
      </ContentNode>

    </LabelList>

  </children>

</component>



My question is: What's the proper way to call the [size=100][font=Arial, Helvetica Neue, Helvetica, sans-serif]XML from the Brightscript?[/font][/size]
Full error message:


BRIGHTSCRIPT: ERROR: roSGScreen: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  1*   ...ailsScreen/DetailsScreen.brs(103)    screen.setMessagePort(m.port)

Current Function:
100:  sub showChannelSGScreen()
101:    screen = CreateObject("roSGScreen")
102:    m.port = CreateObject("roMessagePort")
103:*   screen.setMessagePort(m.port)
104:    scene = screen.CreateScene("LabelListExample")
105:    screen.show()
106:  
107:    while(true)
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
103:   screen.setMessagePort(m.port)
Backtrace:
#1  Function showchannelsgscreen() As Void
   file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(103)
#0  Function onitemselected() As Void
   file/line: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(95)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=3 count:7
screen           Invalid
scene            <uninitialized>
msg              <uninitialized>
msgtype          <uninitialized>
Threads:
ID    Location                                Source Code
 0    pkg:/source/main.brs(20)                msg = wait(0, port)
 1*   ...ailsScreen/DetailsScreen.brs(103)    screen.setMessagePort(m.port)
  *selected

Brightscript Debugger>
Thread detached
>>> Details >> OnkeyEvent

Thread detached
 
User avatar
Tyler Smith
Posts: 101
Joined: Thu Apr 14, 2016 10:51 am
Location: Nova Scotia, Canada
Contact:

Re: How do I call XML code from Brightscript for a Roku Channel?

Mon Aug 14, 2017 5:39 am

http requests cannot be performed on the render thread.
Take a look at https://sdkdocs.roku.com/display/sdkdoc/Task which defines the process in RSG.
Tyler Smith
Senior Developer, REDspace
redspace.com
 
neowinston
Topic Author
Posts: 28
Joined: Thu Feb 09, 2017 6:38 am

Re: How do I call XML code from Brightscript for a Roku Channel?

Mon Aug 14, 2017 6:31 am

Hello Tyler,

Thanks for your answer and of the link!

For me it's not very clear how I call the Task from BrightScript. Would you please give me an example? Thank you!

I'm trying to invoke the task in a BrightSprit file like so (from this link: https://sdkdocs.roku.com/display/sdkdoc ... er+Content):

m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")
m.getHomeOptionsList.observeField("content", "showhomeoptionslist")
m.getHomeOptionsList.functionName = "showhomeoptionslist"
m.getHomeOptionsList.control = "RUN"

Who is online

Users browsing this forum: No registered users and 3 guests