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: 
rsromeo
Channel Surfer

STOPPING A SIMULATED PLAYLIST

I have a simulated playlist working but I have an issue. After each video plays, it advances to the next video in the array. that works great. My problem is the close screen event which occurs after each video is played. How can this be controlled so that when a user presses the UP key on remote, it exits the playlist? Right now, the UP key closes the current video screen and then it loops to the next video giving the user no way to exit other than using the Home key or advancing through all the videos in the array. Here's a sample snipet of code I am using:

For each clip in array

print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

video.SetContent(clip)
video.show()

while true
msg = wait(0, video.GetMessagePort())

if msg.isRemoteKeyPressed()
i = msg.GetIndex()
print "Key Pressed - " ; msg.GetIndex()
if (i = 2) then
print "Up pressed"
goto closecanvas
end if
else if msg.isScreenClosed()
print "Screen closed"
exit while
end if
end while
end for
closecanvas:
canvas.close()
0 Kudos
2 REPLIES 2
RokuChris
Roku Employee
Roku Employee

Re: STOPPING A SIMULATED PLAYLIST

I don't believe roVideoScreen has an isRemoteKeyPressed() event. You will need to be handling events like isFullResult(), and isPartialResult() to make this work properly. You can just keep a flag and check it after each roVideoScreen closes to know whether to continue with the rest of the playlist. This code may not do exactly what you want, I didn't test it, but it should get you started.

shouldPlaylistExit = false

For each clip in array
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

video.SetContent(clip)
video.show()

while true
msg = wait(0, video.GetMessagePort())

if msg <> invalid
if msg.isPartialResult()
shouldPlaylistExit = true
else if msg.isScreenClosed()
print "Screen closed"
exit while
end if
end if
end while

if shouldPlaylistExit
exit for
end if
end for
0 Kudos
rsromeo
Channel Surfer

Re: STOPPING A SIMULATED PLAYLIST

Thanks Chris. It worked!! I just had to reset the flag for each new video.
0 Kudos