Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Level 7

Pagination on the poster screen?

Is there a way to implement pagination on the posterscreen? When loading the contents of reasonably large feeds (on the order of say 200 items), it takes the box about 5-10 seconds to process all of the items.

During this time, user input is processed and it leads to weird interaction behavior.

Another possibility would be displaying some sort of busy cursor (though I'd prefer the speedy and more usable pagination Smiley Wink
0 Kudos
4 Replies
Highlighted
Level 7

Re: Pagination on the poster screen?

The best way to do this is with an web services API that supports paging. Basically, the idea is that the web service supports requests with a starting item and a count so that you can retreive the data in chunks. As the user moves, additional pages are added to the cache for the screen. You can then put up the screen after a small fetch and only get more data if the user starts navigating and needs it. Check out the feedPagable.brs in the youtube application for an example on how you'd do this type of processing.
0 Kudos
Highlighted
Level 7

Re: Pagination on the poster screen?

Can you provide an example to implement pagination, there is no youtube example.
Sample code snippet will be helpful.
0 Kudos
Highlighted
Level 7

Re: Pagination on the poster screen?

"lumaflix" wrote:
Can you provide an example to implement pagination, there is no youtube example.
Sample code snippet will be helpful.


If you take a look at the showFeed.brs file in the videoplayer example, you'll see that they have the beginning of a pagination solution in parse_show_feed

'for now, don't process meta info about the feed size
if curShow.GetName() = "resultLength" or curShow.GetName() = "endIndex" then
goto skipitem
endif



What I did was have my web server return only 20 items at a time, with a maxIndex and endIndex item. (Both zero-based, so I'm comparing indices, not index and length).


if curShow.GetName() = "maxIndex" then
m.maxIndex = curShow.GetText()
print "maxIndex: " + m.maxIndex
goto skipitem
elseif curShow.GetName() = "endIndex" then
m.lastIndex = curShow.GetText()
print "lastIndex: " + m.lastIndex
goto skipitem
endif


Then, in the poster screen code event handler, I check for the isListItemFocused event, and if I'm close to the end of my currently fetched list (less than 6 away), I fetch some more.


else if msg.isListItemFocused() then
'pagination
m.curShow = msg.GetIndex()
' print "list item focused | current show = "; m.curShow
' print "list item focused | last = "; m.lastIndex
' print "list item focused | max = "; m.maxIndex
if (m.lastIndex > 0) then
if ((m.lastIndex < m.maxIndex) and ((m.lastIndex-m.curShow) < 6)) then
screen.ShowMessage("Fetching...")
m.lastIndex = m.lastIndex + 1
m.shows = getShowsForCategoryItem(category, m.curCategory, m.shows)
screen.SetContentList(m.shows)
screen.ClearMessage()
endif
endif



I changed a few of the functions to allow me to pass the current show list into the fetch routine, and the parse routine will accept the show list and append the newly fetched shows to it. You'll also need to pass the start index to your web server in the query string.

I'm passing the indices back from the fetch routine as member variables on the connection object. These end up as variables on the posterScreen object, m.lastIndex and m.maxIndex.

This solved the initial fetch and parse issue for me, and makes the whole thing alot faster. The refetches are fast enough that the "loading..." screen comes and goes almost too fast to see.

Next step is to remember where I am in a particular list, so when I go from one category to another, then back, I stay where I was in the list (rather than starting at 0 again). This will require an initial fetch index, and the ability to page down as well as up. Someday, after I get playback to stop crapping out after an hour...
0 Kudos
Highlighted
Level 7

Re: Pagination on the poster screen?

thanks very much zimbra, this is really helpful. worked like a charm.
0 Kudos