Introduction, Quick example – BrightSign HD2000 BrightScript Reference Guide User Manual

Page 4

Advertising
background image

4

Introduction

Roku BrightScript is a scripting language based on Basic. It is easy to learn, and when combined with Roku
Objects, it allows developers to create the logic needed for interactive signs or kiosks. This document
specifies the syntax and built-in functions of the scripting language. To write useful applications, you should
also refer to the Roku Object reference.

This manual is designed for people that have some experience programming software. It is a reference guide,
not a tutorial.

BrightScript is an interpreted language, and runs on the BrightSign. To write BrightScript you just need a
text editor on your PC or Mac. You can create it using any text editor. I use the editor that comes with
Microsoft Visual Studio, which conveniently does color coding for Basic. Once a script is created, you save
it, copy it to a Compact Flash card, put it in BrightSign, turn on the power, and use a terminal program to
enter the “script <filename>” command. See the BrightSign User Guide for more information on this.

Quick Example

This example will give you a quick flavor of the Roku BrightScript scripting language with a script that plays
a video file.

REM Defaults to 640x480x60p VGA Out

video=CreateObject("roVideoPlayer")
p=CreateObject("roMessagePort")
ok=video.SetLoopMode(1)
ok=video.PlayFile("/autoplay.vob")
msg=wait(0, p)

Let’s go through each line:

REM Defaults to 640x480x60p VGA Out

This line does nothing, it is a “remark”. You use REM or ‘ (apostrophe) to indicate a remark or comment.

video=CreateObject("roVideoPlayer")

The CreateObject function creates a “Roku Object”. See the BrightScript Object Reference for more
information on this. The variable “video” now holds the reference to this object, and has the type
“roVideoPlayer”

p=CreateObject("roMessagePort")

This creates an object of type roMessagePort that is used to receive events.


ok=video.SetLoopMode(1)

This calls the method SetLoopMode of the object roVideoPlayer. This causes the roVideoPlayer to always
loop any video it plays back (forever). The “ok” variable now holds the result of this method call, which
indicates if there was an error or not. There is almost never an error in this case and this script doesn’t
actually check the return code.


ok=video.PlayFile("/autoplay.vob")

Tell the video object to play the file “/autoplay.vob” (autoplay.vob in the root of the Compact Flash card).


msg=wait(0, p)

Wait for an event on the message port p. There will never be one, since the “SetPort” member was never
called. See the discussion on the event architecture in the BrightScript Roku Objects reference manual for
more info. The “0” in “wait” is that timeout value. 0 means never time out. So the net result of this “wait”
is to wait forever, since it will never time out, and p never receives events.

Advertising
This manual is related to the following products: