Roku Developer Program

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

Simple Grid with Details and Video

Newbie question...

I'm trying to understand the logic behind hiding and showing screens in the Simple Grid demo.

So I added a back button in the Details Scene to return to the Home Scene.

I must be doing something wrong because I simply can't make it work.

Any pointers on how to switch between scenes?
0 Kudos
6 Replies
TheEndless
Level 7

Re: Simple Grid with Details and Video

Typically, you'd only have one scene with multiple components that represent each screen. These "screen" components are shown or hidden using their "visible" attribute. The example you're looking at works the same way (i.e., there is no "Details Scene" rather a details screen component that resides in the HomeScene"). In it, the "GridScreen" component is the "home" screen. Look in the OnKeyEvent function in HomeScene.brs and you should see how the back button presses are used to show and hide the details screen.
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
alx
Level 7

Re: Simple Grid with Details and Video

I see that on the HomeScene >> OnkeyEvent the fiscal back button is handled.

But if I do the same on the DetailsScreen the roku freezes.
This is the code I added to to Details Screen:

' on Button press handler
Sub onItemSelected()
print "play button pressed"

' first button is Play
if m.top.itemSelected = 0
m.videoPlayer.visible = true
m.videoPlayer.setFocus(true)
m.videoPlayer.control = "play"
m.videoPlayer.observeField("state", "OnVideoPlayerStateChange")
end if
' second button is Back
if m.top.itemSelected = 1
print "back pressed"

m.gridScreen = m.top.findNode("GridScreen")
m.gridScreen.visible = "true"
m.detailsScreen.visible = "false"
m.gridScreen.setFocus(true)

end if
End Sub


Any idea what I am missing?
0 Kudos
TheEndless
Level 7

Re: Simple Grid with Details and Video

Ah.. you're not trying to capture a remote button press, but rather a poster you've added to the grid. In that case, I think you'd need to set the value of a field on the DetailsScreen that the Scene is observing. Perhaps a field called "close" (similiar to how dialogs work). The scene will observe that field and change the visibility when it's value changes.

The code above won't work, because your details screen doesn't have a reference to m.gridScreen or m.detailsScreen. Those are defined in the scene script.
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
alx
Level 7

Re: Simple Grid with Details and Video

Yes, I'm trying to add a back button on screen.

This is what the debugger is showing:

086: m.gridScreen = m.top.findNode("GridScreen")
087:* m.gridScreen.visible = true
Invalid value for left-side of expression. (runtime error &he4) in ...



Or is there a way to create a "back-button pressed" event?
0 Kudos
TheEndless
Level 7

Re: Simple Grid with Details and Video

"alx" wrote:
Yes, I'm trying to add a back button on screen.

This is what the debugger is showing:

086: m.gridScreen = m.top.findNode("GridScreen")
087:* m.gridScreen.visible = true
Invalid value for left-side of expression. (runtime error &he4) in ...
Or is there a way to create a "back-button pressed" event?

That's because the DetailsScreen doesn't know about GridScreen. GridScreen is part of the Scene, not the DetailsScreen, so running m.top.findNode in DetailsScreen is going to return invalid, resulting in the error you're getting. You'll need to add a field to DetailsScreen that the Scene can observe, so it can close the DetailsScreen.
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
alx
Level 7

Re: Simple Grid with Details and Video

Thanks for your help. I'm still struggling to get a grip on how to "close" the DetailsScreen.



is there a way to create a "back-button pressed" event?
0 Kudos