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: 
djp
Visitor

roSearchScreen Results Help

Hello guys,

I have a PHP background, but I am totally new to RoKu/BrightScript development, although I seem to do be doing pretty well for having a pretty well polished app so far from just scouring and figuring things out so far, I was hoping it didnt have to come to this, but I must ask for help I have exhausted all of my searching on this so far.

I have used the videoplayer application as a starting point, I have managed to get a link page working and the search screen appended to the category xml that the videoplayer uses as a main screen.

Here is what I cannot for the life of me get working. I would like the search results from the roSearchScreen to post to a xml page http://example.com/roku/search.php?search=STRING so i can create a category xml file on the fly and take it to a poster view with the results.

I tried duplicating the showHomeScreen() function to no success.

Anyone who can help me with this, I will be greatly indebted to you and would love to help you out with anything
0 Kudos
4 REPLIES 4
belltown
Roku Guru

Re: roSearchScreen Results Help

You could do something like this to get the content list Xml from the search screen. Once you have that, write whatever code you need to display them on a poster screen:

Sub Main()
displaySearchUI ()
End Sub

Function displaySearchUI () As Void
port = CreateObject ("roMessagePort")
searchHistory = CreateObject ("roSearchHistory")
searchHistoryList = searchHistory.GetAsArray ()
ui = CreateObject ("roSearchScreen")
ui.SetMessagePort (port)
ui.SetSearchTermHeaderText ("Enter Search Terms")
ui.SetSearchTerms (searchHistoryList)
ui.SetSearchButtonText ("Search")
ui.SetClearButtonEnabled (True)
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roSearchScreenEvent"
If msg.IsPartialResult () ' Event fired for every character entered
result = msg.GetMessage () ' Partial string - all characters entered so far
partialSearchList = CreateObject ("roArray", searchHistoryList.Count (), False)
For Each item In searchHistoryList
If Len (item) >= Len (result) And Left (item, Len (result)) = result
partialSearchList.Push (item)
EndIf
End For
ui.SetSearchTerms (partialSearchList) ' Display search history items that match partial search chars
Else If msg.IsFullResult ()
searchTerm = msg.GetMessage ()
searchHistory.Push (searchTerm)
displaySearchResults (searchTerm)
Else If msg.IsCleared ()
searchHistory.Clear ()
Else If msg.IsScreenClosed ()
Exit While
EndIf
EndIf
End While
End Function

Function displaySearchResults (searchTerm As String) As Void
contentList = CreateObject ("roXmlElement")
ut = CreateObject ("roUrlTransfer")
url = "http://example.com/roku/search.php?search=" + ut.Escape (searchTerm)
ut.SetUrl (url)
data = ut.GetToString ()
If data = ""
Print "No data returned from: "; url
Else
If Not contentList.Parse (data)
Print "Unable to parse Xml data:"
Print data
Else
displayPosterUI (contentList)
EndIf
EndIf
End Function

Function displayPosterUI (contentList)
Print "Displaying poster screen"
End Function
0 Kudos
djp
Visitor

Re: roSearchScreen Results Help

thank you, I have implemented your code and seems to be debugging correctly, how could i pass the contentlist to the xml parser thats already provided with the videoplayer sample to create a posterview??
0 Kudos
belltown
Roku Guru

Re: roSearchScreen Results Help

It depends on what the Xml is that you get from your search query. If it's a <Category> element then you may be able to call ParseCategoryNode() to get a top-level node that you can pass to showPosterScreen(). The exact details, I'll leave to you to figure out. You'll probably have to spend some time actually figuring out how the example code works so you can change it to do what you want, which is the whole point of the SDK "examples"; they're more of a learning tool than a template.
0 Kudos
djp
Visitor

Re: roSearchScreen Results Help

Thank you sir, I was actually able to get this to work!
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.