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

Favorite Catagory

Does anybody have aby sample code to add a favorite catagory?

When you first enter in to my channel, I might have 50 selections. I want to add the first selection as my favorite or even last viewed.

Is this built in to the Roku SDK or does the Player "post" back to our servers and and we store this?
0 Kudos
4 REPLIES 4
destruk
Binge Watcher

Re: Favorite Catagory

It'd be simplistic to add a button to the detail screen for 'add to favorites'. Probably below the resume and play from beginning buttons. You could even store the value in the roku's own registry with a limit of say a top 10 content index list with RegWrite. Or you could add another get request to have your server (generating the category and content xml) create the user's favorites based on the box serial number linked to their account. Those are the two ways that come to mind for me.
0 Kudos
bbakernc
Visitor

Re: Favorite Catagory

Sounds good, have you seen any documention on either of these two ways?
0 Kudos
destruk
Binge Watcher

Re: Favorite Catagory

Documentation? sure! 😉
In the video player SDK example - AppDetailScreen.brs - probably in RefreshShoeDetail since that is called first when the screen is initialized, you already have
screen.AddButton(1, "resume playing")
screen.AddButton(2, "play from beginning")

You might want to add a third button with a number 3 there for "Add to Top Ten"

In the same file for showDetailScreen - which has the input loop for that section, you have a part which says -
else if msg.isButtonPressed()
print "ButtonPressed"
print "ButtonPressed"
if msg.GetIndex() = 1

You can delete the prints, since those are debug. The index of the button you added would be #3 - and have it call a dialog window to add to the top ten category.
The code for dialogs is in generaldlgs.brs

Generalutils.brs has these routines in it

Function RegRead(key, section=invalid)
if section = invalid then section = "Default"
sec = CreateObject("roRegistrySection", section)
if sec.Exists(key) then return sec.Read(key)
return invalid
End Function

Function RegWrite(key, val, section=invalid)
if section = invalid then section = "Default"
sec = CreateObject("roRegistrySection", section)
sec.Write(key, val)
sec.Flush() 'commit it
End Function

Function RegDelete(key, section=invalid)
if section = invalid then section = "Default"
sec = CreateObject("roRegistrySection", section)
sec.Delete(key)
sec.Flush()
End Function

To use those you could say something like RegRead ("NumberofFavorites","Favorites")
One name/value pair per key.

You can have it read keys as soon as your channel initializes, in app main for your channel, so they would populate from those keys to create the content list of the favorites category, and you could add code within the favorites category display to remove items that are selected from the favorites list too, or in the detail screen, whichever is easier. If you are concerned about limitations of keys in the roku flash ram, then you might also consider the server route. If yoiu already have a streaming server with a database backend that you use for linking and registration, then you could simply have the server send the user's favorites to them every time the channel is opened when you check to see if they are authorized users via serial number and verifying their account info on your server. Look at the registration and linking sample SDK code for that.
0 Kudos
bbakernc
Visitor

Re: Favorite Catagory

This is GREAT......

I will have to figure out where to put this.......

I am build my channel with "sub-channels" simular to Roku News channel. My viewers can select my channel and there might be 30 sub-channels displied, so that is where I need to use the "favorite" button. So I guess the 'SAVE' button would have to be where I display catagories and videos to watch.

THANKS
0 Kudos