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

Play All button for mrss_template channel

I've searched and read through the various discussions on adding a Play All button, but everything I've seen is using the videoplayer example channel. Has anyone added code to the mrss_template channel to add a Play All feature? I've been digesting the code flow and I'm still confused on what changes I need to make. If you're familiar with the mrss_template, would you be kind enough to help me add the appropriate code? I'd appreciate and help. If you need to see various functions in the code, I can post it here.
Thanks
~Mark
0 Kudos
4 REPLIES 4
RokuJoel
Binge Watcher

Re: Play All button for mrss_template channel

First, you need to conditionally add a button to function ShowSpringboardScreen() if there is more than one video in the list:

if episodes.count() > 1 then 
screen.addbutton(2,"Play All")
end if


Now we need to handle that button if it is pressed:

		else if msg.isButtonPressed()
if msg.getindex()=1 then
ShowVideoScreen(episodes[selectedEpisode])
else if msg.getindex()=2 then
while selectedEpisode < episodes.count() -1
ShowVideoScreen(episodes[selectedEpisode])
if selectedEpisode <episodes.count()-1
selectedEpisode=SelectedEpisode+1
end if
end while
end if


There is more: you need to modify the ShowVideoScreen to return a value that tells the calling function if playback was interrupted by the user, and if so exit the loop, otherwise when a user exits, instead of going back to the Springboard, the next video will play. You should be able to implement this by tacking in an

Else If msg.ispartialresult() then return -2

and checking for that value when you call the video player:

test=ShowVideoScreen(episodes[selectedEpisode])
if test=-2 then exit while


Of course, this is a rough outline, and you might have to do a little bit more work than that to make it work smoothly, but that is the gist of it
0 Kudos
agmark
Visitor

Re: Play All button for mrss_template channel

Thank you Joel! I'll work on that shortly. I follow everything except the last "test" routine. Where would that go? Back in the ShowSpringboardScreen where the ShowVideoScreen is called or the ShowVideoScreen function? There are several while loops and I'm not clear on where that one would go.

I appreciate your help. It's so much more clear when I see it done correctly 🙂

I work on it and let you know.
~Mark
0 Kudos
RokuJoel
Binge Watcher

Re: Play All button for mrss_template channel

In the showSpringboardScreen() function:

 else if msg.getindex()=2 then
while selectedEpisode < episodes.count() -1
test=ShowVideoScreen(episodes[selectedEpisode])
0 Kudos
agmark
Visitor

Re: Play All button for mrss_template channel

Awesome Joel. That did it. Seems to work great, but I'll keep testing. The only change I had to make was to change msg.ispartialresult() to msg.ispartialResult().
Else If msg.ispartialresult() then return -2 


Debug gave me an error until I changed it. I'm never sure if case makes a difference, but apparently does with these events. Weird that it's listed in the Component Reference as isPartialResult. I would think that if case mattered it still wouldn't work as ispartialResult. I suppose I could go back and test it again, but I hate to break it now that I finally got it working right.

Thanks again for your quick help. Things are starting to jell a little more everytime I see results.
~Mark
0 Kudos