7
t.PushString("BrightSign solid-state media players power
interactive video exhibits with simplicity, reliability and
interactivity to high-impact digital signage. Learn more at
www.roku.com/brightsign.")
t.Show()
p=CreateObject("roMessagePort")
sw = CreateObject("roGpioControlPort")
sw.SetPort(p)
msg_loop:
msg=wait(0,p)
if type(msg)="roGpioButton" then
if debug AND msg=12 then 'Video Select
end
endif
else
print "Unknown event "; type(event)
endif
goto msg_loop
BrightSign Object Library
This section specifies each of the Roku Objects that are included with BrigthScript.
Event Loops
When creating anything more than a very simple script, an Event Loop will need to be created. An Event
Loop typically has this structure:
1. wait for the event
2. process the event
3. jump back to 1
Events are things like a button press, a timer that has triggered, a video that has finished playing back, etc.
By convention, Roku Object (RO) events work as follows.
• A RO of type “roMessagePort” is created. In BrightScript, by the user’s script.
• ROs that can send events are instructed to send their events to this message port. You could set up
multiple message ports, and have each event go to its own message port, but it is usually simpler
to just create one message port, and have the events all go to this one port. To instruct the RO to
send events to a specific port, use the ifSetMessagePort Interface.
• The script waits for an event. The actual function to do this is the ifMessagePort.WaitMessage(),
but if you are using BrightScript, the built-in statement WAIT makes this easy.
• If multiple event types are possible, your script should determine which event that the wait
received, then process it. The script then jumps back to the Wait.
An “Event” can be generated by any Roku Object. For example, the class “roGpioControlPort” sends
events of type “roGpioButton”. The “roGpioButton” has one interface: ifInt. ifInt allows access to an
integer. An event loop needs to be aware of the possible events it can get, and process them.