btpoole
11 years agoChannel Surfer
Detect Remote Button During VideoScreenEvent
Looking for some suggestions or help for the following. Currently have a channel that plays video thru roVideoScreen. Everything works as planned with the following exception. After the video starts part of the code is a while true that waits for a port message, if the message is roVideoScreenEvent it checks if a remote button was pressed, if so it prints the button index, if not it ignores this part. During video play I can press the pause, resume, rewind etc and they work but the index never appears in the debug. I am wishing to assign a value to one of the less used buttons to have an event occur if the that button is pressed during play. Any help greatly appreciated.
lastSavedPos = 0
statusInterval = 10 'position must change by more than this number of seconds before saving
while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
exit while
elseif msg.isRemotePressed()
print "button pressed: ";msg.GetIndex()
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
PRINT msg.GetIndex()
if nowpos > 10000
end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
end if
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while