Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

Re: Beta Scene Graph Components

Is the beta firmware still being provided via PM request or is it now just rolling out to the general public in batches?

Just curious as I sent a PM a couple days ago.

Thanks.
0 Kudos
Level 7

Re: Beta Scene Graph Components

How about creating one Dialog from another?
Here's my code:

function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if (press)
if(key = "options")
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "Settings"
m.top.dialog.message = "WOWOWOW"
buttons = ["First", "Second"]
m.top.dialog.buttons = buttons
m.top.dialog.ObserveField("buttonSelected", "DialogButtonSelected")
handled = true
end if
end if
return handled
end function

sub DialogButtonSelected()
if(m.top.dialog.buttonSelected = 0)
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "FIRST"
m.top.dialog.message = "FIRST"
else
m.top.dialog = CreateObject("roSGNode", "Dialog")
m.top.dialog.title = "Second"
m.top.dialog.message = "second"
end if
end sub



After selecting any of buttons my roku stick reboots and telnet gets disconnected. How can I do what I need?
0 Kudos
Level 7

Re: Beta Scene Graph Components

Hi Everyone,

I ran into an issue while using the getChild() from a node. It seems to return child nodes which do not exist within the parent node.

Here's an example of what I tried:

MainComponent:

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

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

<script type="text/brightscript" uri="pkg:/components/Managers/FocusManager.brs" />

<children>

<Navigation id="MainNav" />

<CustomLabel id="csLbl" translation="[300, 200]" />

</children>

</component>


FocusManager.brs

function init()

' The below two lines work as expected. Both returns the right nodes within the parent
m.lbl = m.top.findNode("csLbl")
m.mainNav = m.top.findNode("MainNav")

' Returns a node that is not existing in above component
m.mnNav = m.top.getChild(0)
' Returns a node that is called LayerRoot. What is LayerRoot ?
m.mnlbl = m.top.getChild(1)

m.top.SetFocus(true)
end function


In above example

the Navigation component is a simple component that extends LayoutGroup and CustomLabel is a component that extends Group.

Is there a reason why getChild() would return something that's not a child ? or Am i doing something wrong here.

Any help would be great as I need to find a way to access the children within a parent node through index values.

Thanks,

Mark
0 Kudos
Level 7

Re: Beta Scene Graph Components

I have been trying unsuccessfully to set up a Task to attempt a post request. I am able to retrieve a JSON response from the server with a 200 response. I then assign the return value to a contentNode.

UrlTransfer works successfully and I am able to print out the response in full and parse into a ContentNode
Function http_post_from_string_with_timeout(val As String, seconds as Integer) as String
timeout% = 1000 * seconds

str = ""
m.Http.EnableFreshConnection(true) 'Don't reuse existing connections
print "url string" + val
if (m.Http.AsyncPostFromString(val))
event = wait(timeout%, m.Http.GetPort())
if type(event) = "roUrlEvent"
url_status = "Communication Response Code: " + str(event.GetResponseCode())
print "url_status " + url_status
print "event.GetFailureReason() " + event.GetFailureReason()
print "event.getString()" + event.GetString()
print "GetResponseHeaders " event.GetResponseHeaders()
if ( event.GetResponseCode() <> 200 ) then
else 'its a good response
str = event.GetString()
end if
elseif event = invalid
print "2"
m.Http.AsyncCancel()
else
print "3"
endif
endif

return str
End Function


I have set up observers in the main group to watch for the task to complete. The session function never fires and the state only returns an "INIT", never "DONE"
m.connection.observeField("content", "sessionLookup")
m.connection.observeField("state", "stateLookup")
m.connection.functionName = "getContent"
m.connection.control = "RUN"


What could be preventing the observers from never completing or triggering? Has anyone have any ideas why the Task is not allowing to proceed? I am at a standstill and don't know want else to try... Any help would be appreciated.

I am using these helper functions for url transfers : https://github.com/sunlightlabs/roku-wh ... lUtils.brs
0 Kudos
Level 9

Re: Beta Scene Graph Components

"edskitter" wrote:
What could be preventing the observers from never completing or triggering? Has anyone have any ideas why the Task is not allowing to proceed? I am at a standstill and don't know want else to try... Any help would be appreciated.

You didn't share your "getContent" function, which is where, presumably, you're updating the "content" field. Can you share that and your Task XML definition?

Also, it's worth nothing that the "state" value is actually in lowercase, not uppercase as documented, so you might be overlooking that update, if you're explicitly looking for an uppercase value.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Level 7

Re: Beta Scene Graph Components

Task xml.

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

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

<component name="connection" extends="Task" >

<interface>
<field id="uri" type="string" />
<field id="content" type="node"/>
<field id="route" type="string" />
<field id="accountid" type="string" />
<field id="accountpassword" type="string" />

</interface>

<script type="text/brightscript" >
<![CDATA[

sub init()
'm.top.functionName = "getContent"
end sub

sub getContent()
http_headers = CreateObject("roAssociativeArray")
http_headers.Content_Type = "application/x-www-form-urlencoded"

post_string$ = "account_id=" + m.top.accountid + "&account_pin=" + m.top.accountpassword + "&app_version=1.0" + "&serial_number=" + getDeviceESN()

http = NewHttpJSON(m.top.uri, http_headers)

content = http.PostFromStringWithTimeout(post_string$, 30)

content = parseJSON(content)
print content
contentnode = createObject("RoSGNode","ContentNode")
contentnode.telcoid = content.telco.id
contentnode.url_sms = content.telco.url_sms
contentnode.support = content.telco.support
contentnode.account_id = content.user.account_id
contentnode.account_pin = content.user.account_pin
contentnode.account_state = content.user.account_state

m.top.content = contentnode
print "gets here fine"

end sub


For the state observer function, I am just pringting out the

sub stateLookup() 

print "m.connection.state: " + m.connection.state
end sub


Thanks Endless for looking at this.
0 Kudos
Level 9

Re: Beta Scene Graph Components

When I run that, I get state values of "run" and "stop". Never "done", but that might be expected (??). I also correctly get a "sessionLookup" call immediately before the "stop" state, so it seems to be working as expected. Where are you creating and running the connection task? In my test, I kicked it off in init().

One thing to note, which may or may not be related to the issue you're seeing... ContentNode fields are limited to those listed in the Content Meta-Data section of the docs, so even if you do get your sessionLookup callback, you won't be able to retrieve the fields you populated. If you want custom fields, you'll need to create a custom component that extends ContentNode with the additional interface fields.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Level 7

Re: Beta Scene Graph Components

Hello Endless,

Thank your for your response. I initially had the task component being initialized inside a custom node which extended Group. I then moved the Task to the main Scene and like you, received a run and stop, never a DONE status. So progress Smiley Very Happy

Saying that, what would you recommend to return so I can use the values application wide? Is extending the ContentNode the best choice in your opinion? I want to be able to work with standard values returned ( sessions, first name, last name etc.) from a login route.

How would you go about extending the ContentNode to use in the main scene?
0 Kudos
Level 9

Re: Beta Scene Graph Components

"edskitter" wrote:
Hello Endless,

Thank your for your response. I initially had the task component being initialized inside a custom node which extended Group. I then moved the Task to the main Scene and like you, received a run and stop, never a DONE status. So progress Smiley Very Happy

Saying that, what would you recommend to return so I can use the values application wide? Is extending the ContentNode the best choice in your opinion? I want to be able to work with standard values returned ( sessions, first name, last name etc.) from a login route.

How would you go about extending the ContentNode to use in the main scene?

I'd probably just return an associative array, or the raw parsed JSON. The only reason to do it as a ContentNode would be if you were needing to pass it to one of the components that requires ContentNodes (e.g., PosterGrid).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Level 7

Re: Beta Scene Graph Components

How do you secure video with the new component?
0 Kudos