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: 
joetesta
Roku Guru

questions about handling starratings

Hi -

I have included the 'AddRatingButton' so the user can vote on titles and I'm trying to figure out the logistics. I didn't find anything about this in the docs or forum, does anyone have advice about implementing it?
Here are my questions:

1. Is there an easy way to save their vote so that once the user browses to a different title and then browses back to the title they voted on, their earlier vote will still be shown? Would the app need to connect to the server / db to get the user's previous rating for each title page they browse? (not liking that idea) Alternatively, each time they return to the page they'd see the default rating and would be able to recast their vote (replacing their earlier vote for the same title)

2. At what point should the average ratings be generated for inclusion in the XML?
a) each time the app is launched, re-calculate all average ratings?
b) each time a user votes, recalculate the average rating for just that title?
c) periodically (every 6 hours) recalculate all average ratings?
(I'm thinking a combination of b and c, where the average rating gets recalc'd on the fly but the XML is only regenerated a few times per day)

tyvmia,
Joe
aspiring
0 Kudos
10 REPLIES 10
SkipFire
Visitor

Re: questions about handling starratings

The better option would to be put the value in a database that you can read from later. However, if you want to avoid the database option you could write the value to the registry and read back from the registry later. Several examples of registry functions in a utils file, just look for roRegistry.
0 Kudos
joetesta
Roku Guru

Re: questions about handling starratings

thanks Skipfire - i was thinking it would be inefficient to make an additional web / db call on every single page. but maybe that is the way to go...? Will check out using the registry functions, thank you!
aspiring
0 Kudos
SkipFire
Visitor

Re: questions about handling starratings

Just pass the user's star rating in place of the average if the user has submitted one, then it is included in the XML response that has all the data and doesn't result in extra calls to get the value. I don't know how much space the registry has and if you have a really big number of videos you could run into problems. Plus you would have to be sure the naming of the values can stay unique. DB is the better way to go if you can.
0 Kudos
destruk
Streaming Star

Re: questions about handling starratings

You wouldn't need to download the star rating on every page. If you are downloading the xml for an entire poster screen, then you download the star ratings with the meta data for all the content on the poster screen and pass the entire listing of items to the detail screen. That way the user can use the left and right buttons on the remote to scroll through on the detail screen without needing to interact with the server again unless they 'rate' something.
0 Kudos
joetesta
Roku Guru

Re: questions about handling starratings

Hi guys, thanks for your replies. But I think you are missing the point of my question (1). I understand I can pass the user's rating within the XML but my question was when the user does not reload the XML; ie browsing to the next title then back to the title they rated. Their rating would appear to the user to be lost / not recorded, until the next time they load the XML. Or are you saying the XML should be reloaded on every page call? I used the videoplayer example and load the XML for many titles at once.

And now I know there are (at least) 2 ways to address it - a web / db call on every page load or a registry call at the same point.
aspiring
0 Kudos
SkipFire
Visitor

Re: questions about handling starratings

I believe the in-memory XML objects can be manipulated.
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: questions about handling starratings

"joetesta" wrote:
Hi guys, thanks for your replies. But I think you are missing the point of my question (1). I understand I can pass the user's rating within the XML but my question was when the user does not reload the XML; ie browsing to the next title then back to the title they rated. Their rating would appear to the user to be lost / not recorded, until the next time they load the XML. Or are you saying the XML should be reloaded on every page call? I used the videoplayer example and load the XML for many titles at once.

And now I know there are (at least) 2 ways to address it - a web / db call on every page load or a registry call at the same point.


Maybe I'm not understanding what you're trying to do, but if you're just talking about the user's rating, that is stored in the userStarRating attribute of the content-meta-data structure. Just modify the value there in memory during the session and don't worry about the XML at all.
0 Kudos
RokuJoel
Binge Watcher

Re: questions about handling starratings

You might wish to implement separate calls to your server to set and get the star ratings for a video, for example:

set star ratings:
http://myserver.com/api/SetStarRating?authtoken=FZXXY&videoUniqueID=AZ7YZ&DeviceSerialNumber=13A12X1...

get star rating:
http://myserver.com/api/GetStarRating?videoUniqueID=AX7YZ&authtoken=FZXXY

that would returns either the value as a text string or XML. That way, you wouldn't have to reparse your full XML each time as the user browses from one item to the next.

- Joel
0 Kudos
joetesta
Roku Guru

Re: questions about handling starratings

Thank you very much guys,
Just modify the value there in memory during the session and don't worry about the XML at all.

Is there an example somewhere showing the proper sytnax for doing this within the videoplayer example?

here's what I'm trying, on appDetailScreen.brs I am seeing the ratings come in, but is it getting stored in memory?
                if msg.GetIndex() = 4
' update userStarRating
print "Rating received: "; msg.GetData()
showList[showIndex].StarRating = msg.GetData()
endif


Then in showFeed.brs I tried this:
        item.StarRating = validstr(curShow.StarRating)

and since that didn't work I also tried this:
        item.StarRating = validstr(curShow.StarRating.GetText())


I don't know what I'm doing, it's not working.
tyvmia for any help.
aspiring
0 Kudos