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()

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

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