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: 
squirreltown
Roku Guru

No loop

Is there a way to get an Event, for instance an roAudioplayer status message without a message loop? Or to make a loop that loops once and exits?
I need to get the info at the start of a function, in the first couple of lines and have been unable to make a loop that doesn't take over and mess things up.

thanks
Kinetics Screensavers
0 Kudos
3 REPLIES 3
destruk
Streaming Star

Re: No loop

http://sdkdocs.roku.com/display/sdkdoc/Event+Loops

"end while"/"exit while" exits a message loop. So if you have this code -


port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetMessagePort(port) ' instruct screen to send events to port
screen.Show()
while true
msg = wait(0, port) ' wait for a message
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return -1
elseif msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()
else
' ignore other unknown or uninteresting roSpringBoardScreenEvents
endif
else
' ignore other events, not type roSpringboardScreenEvent
endif
end while


and you change it to


port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetMessagePort(port) ' instruct screen to send events to port
screen.Show()
while true
msg = wait(0, port) ' wait for a message
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return -1
elseif msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()

EXIT WHILE

else
' ignore other unknown or uninteresting roSpringBoardScreenEvents
endif
else
' ignore other events, not type roSpringboardScreenEvent
endif
end while


Then when a button is pressed it will leave the loop.
0 Kudos
squirreltown
Roku Guru

Re: No loop

Thank you destruk, those docs make a lot more sense after you explain something. I had tried the exit while , but i think i wasn't tying it to an event, i was just hoping it would exit on its own which it didn't seem to, or did but didn't exit properly. You really helped me out this morning, i appreciate it.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: No loop

Well in the end i got the same results as yesterday, that is any kind of loop, even the one you posted - prevents the springboard from reopening, and stops other things from working. Arrgg.
Kinetics Screensavers
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.