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

Free Preview Category

After getting our token authentication completed, I realized one of our end goals is not met with the current set-up. We'd like to have a category which can be accessed by anyone and does not require token authentication.

Currently, our development channel requires authentication to get to any category.

How do I make it so one category, a free preview category, is available without token authentication?

Currently, the modified regScreen.brs from the Register example in the SDK has been placed in my modified videoplayer example from the SDK, and I call it through appHomeScreen.brs here:

else if msg.isListItemSelected() then
doRegistration()
print "list item selected | index = "; msg.GetIndex()


Do I need to call the doRegistration() from somewhere else? Or is there a way to specify that just one category is accessible without registration?
0 Kudos
7 REPLIES 7
SkipFire
Visitor

Re: Free Preview Category

You could put an flag attribute on the category of "IsPreview" and only call doRegistration if IsPreview = false.
0 Kudos
ShifterFilms
Visitor

Re: Free Preview Category

What do you mean by a "flag attribute" ? I searched the forum and could not find any example.

How is that coded?
0 Kudos
ShifterFilms
Visitor

Re: Free Preview Category

Is there a way in the BrightScript (and I'm using a modified version of the videoplayer in the SDK, but the part calling the categories.xml is modified little to none) to say basically

if iscategory1 load the feed else doRegistration() then load the feed ?

So basically the first category listed in categories.xml will load the content for everyone, but any subsequent categories, token validation would be required for access.

I think this is the most simple solution to what I need, but I do not know how to code it or if it is possible.

Thank you for your help, this is the LAST thing we need prior to submitting our public channel.
0 Kudos
belltown
Roku Guru

Re: Free Preview Category


else if msg.isListItemSelected() then
if msg.GetIndex () > 0 then doRegistration()
print "list item selected | index = "; msg.GetIndex()
0 Kudos
ShifterFilms
Visitor

Re: Free Preview Category

belltown -

Thank you so much! I think that your solution is exactly what I need, but I've run across one other roadblock. When clicking the free preview category (the first category listed), it does not load if the device is not linked.

I believe this is because of this function:

Function displayCategoryPosterScreen(category As Object) As Dynamic

if isLinked() then

if validateParam(category, "roAssociativeArray", "displayCategoryPosterScreen") = false return -1
screen = preShowPosterScreen(category.Title, "")
print "attempting to show Poster Screen for " + category.Title
showPosterScreen(screen, category)

return 0
else
return 1
end if

End Function


That function was modified in appHomeScreen.brs to prevent someone from being able to back out of the registration code page and still access the content. Is there a better way to do this, or how do I modify that function to allow access to the first category when the device is not linked?

Also, here is the full showHomeScreen(screen) function (now modified with your code from above) for the first piece, if that is needed, too.

Function showHomeScreen(screen) As Integer

if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1

initCategoryList()
screen.SetContentList(m.Categories.Kids)
screen.SetFocusedListItem(1)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
else if msg.isListItemSelected() then
if msg.GetIndex () > 0 then doRegistration()
print "list item selected | index = "; msg.GetIndex()
kid = m.Categories.Kids[msg.GetIndex()]
if kid.type = "special_category" then
displaySpecialCategoryScreen()
else
displayCategoryPosterScreen(kid)
end if
else if msg.isScreenClosed() then
return -1
end if
end If
end while

return 0

End Function
0 Kudos
belltown
Roku Guru

Re: Free Preview Category

The simplest way to do this would be to pass a parameter into displayCategoryPosterScreen () to indicate whether linking is required:


Function displayCategoryPosterScreen(category As Object, linkingRequired as Boolean) As Dynamic

if not linkingRequired or isLinked() then



and in showHomeScreen () replace:

displayCategoryPosterScreen(kid)


with:


if msg.GetIndex () > 0 then
displayCategoryPosterScreen(kid, true)
else
displayCategoryPosterScreen(kid, false)
endif
0 Kudos
ShifterFilms
Visitor

Re: Free Preview Category

That... worked perfectly! I can't thank you enough. I can now package the channel and get 'er done.

Sending you a PM, belltown, you saved me a lot of headache with your quick replies.
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.