Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Channel Surfer

Reload main screen with new content?

The YouTube app let's you search for media from the main poster screen, it then returns you to the Mainposter screen and appends the results to the posteritems displayed in the search section. How would one go about calling search, and having the program flow return to the main poster screen?

If main calls a poster screen which calls search which calls the main poster screen, won't that result in a stack buildup which should eventually cause a memory or stack overflow?

    Main()
      Posterscreen()
        Search()
          Posterscreen()
            Search()
              Posterscreen()
                Search()

Etc....
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
5 REPLIES 5
jbrave
Channel Surfer

Re: Reload main screen with new content?

How would you redisplay the main poster screen? Would it just auto update or do you need to call poster screen.show() again?
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: Reload main screen with new content?

"jbrave" wrote:
How would you redisplay the main poster screen? Would it just auto update or do you need to call poster screen.show() again?

A call to SetContentList() should redraw the screen, but I just deleted my original reply in favor of something that makes more sense... 😛

The way I deal with it in my SHOUTcast and justin.tv channels is to have the Search screen just return the search string, and then do the actual search from my Poster screen based on the returned 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
TheEndless
Channel Surfer

Re: Reload main screen with new content?

And an example...

Here's my simplified SearchWindow "class"...
Function NewSearchWindow() As Object
search = {
Screen: CreateObject( "roSearchScreen" ),
EventPort: CreateObject( "roMessagePort" ),
History: CreateObject( "roSearchHistory" ),

Show: Search_Show,
Init: Search_Init,
ListenForEvents: Search_ListenForEvents
}
search.Init()
return search
End Function

Sub Search_Init()
m.Screen.SetMessagePort( m.EventPort )
m.Screen.SetSearchTermHeaderText( "Previous searches:" )
m.Screen.SetSearchButtonText( "Search" )
m.Screen.SetClearButtonText( "Clear Search History" )
m.Screen.SetBreadcrumbText( "", "Search" )
m.Screen.SetSearchTerms( m.History.GetAsArray() )
End Sub

Function Search_Show()
m.Screen.Show()
Return m.ListenForEvents()
End Function

Function Search_ListenForEvents()
While True
msg = Wait( 1000, m.EventPort )
If msg <> invalid Then
If Type( msg ) = "roSearchScreenEvent" Then
If msg.IsCleared() Then
m.History.Clear()
print "cleared"
Else If msg.IsPartialResult() Then
print msg.GetMessage()
Else If msg.IsFullResult() Then
m.History.Push( msg.GetMessage() )
m.Screen.Close()
Return msg.GetMessage()
Else If msg.isScreenClosed() Then
Return "Cancel"
End If
End If
End If
End While
Return "Cancel"
End Function

From my poster screen, I do something like this:

If buttonSelected = "Search" Then
searchWin = NewSearchWindow()
searchTerm = searchWin.Show()
If searchTerm <> invalid And searchTerm <> "Cancel" Then
'Do search based on searchTerm
End If
End If
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
jbrave
Channel Surfer

Re: Reload main screen with new content?

So the buttonpressed func is called from the poster screen msg loop?
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: Reload main screen with new content?

Yeah, however you trigger that in your channel. In my case, I have a "Search" content item in my content list. If that one's selected, I call the code above.
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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.