Page 2
Table of Contents INTRODUCTION ..........................4 ROKU OBJECT INTERFACES AND METHODS ................4 INHERITANCE ..........................5 CLASSES............................5 OBJECT AND CLASS NAME SYNTAX..................5 ZONES ............................5 BRIGHTSIGN OBJECT LIBRARY ....................7 ..........................7 VENT OOPS ............................8 LASSES roList..............................8 roMessagePort............................
Roku Objects (RO) are the standardized way Roku software exposes functionality for our products’ public SDKs. In other words, to publish a new API, Roku will create a new Roku Object. The first product to use this method is the BrightSign. Roku Objects have these key objectives: To be largely language independent.
• Zones With the BrightSign Zones feature, you can divide the screen into rectangles and play different content in each rectangle. A zone can contain video and images, images, a clock, or text. There can be only one video zone per screen.
Page 6
Example: This script creates 5 zones. The first one contains a video player, the next two contain image players, the fourth has a clock widget and the last is a text widget. The objects used in this example are explained in subsequent sections of this document.
roMessagePort A message port is the place messages (events) are sent. See the “Event Loops” section for more details. When using Roku BrightScript, you would not call these functions directly. Instead, use the “Wait” BrightScript statement (see the BrightScript documentation). Interfaces: ifMessagePort •...
GetSafeHeight() As Integer ifVideoMode • SetPowerSaveMode(power_save_enable As Boolean) As Boolean ifSetMessagePort • SetPort(obj As Object) As Void Supported modes that can be passed to SetMode on the HD110, HD210, HD410, HD810 and HD1010 are: “auto” • “640x480x60p” • “800x600x75p” •...
Page 11
If the mode is set to ‘auto’, BrightSign will try to determine the best video mode to use based on connected hardware. The algorithm is: Try VGA first – if VGA is attached use the best mode as reported by the monitor.
Currently only MPEG2 files are supported by BrightSign • On the HD110, HD210, HD410, HD810, and HD1010, only MPEG2 transport streams are • supported. Audio can be either AC3 or MP3, however AC3 audio will currently not be decoded on the BrightSign –...
Page 13
Users can add events which trigger messages of the roVideoEvent “Timecode Hit” at the specified millisecond times in a video file. The data field of the roVideoEvent holds the userdata passed in with AddEvent. Here is an example script that uses timecode events. The script prints out 2, 5 and 10 at 2 seconds, 5 seconds and 10 seconds into the video.
roAudioPlayer An audio player is used to play back audio files (using the generic ifMediaTransport Interface). If the message port is set, the object will send events of type roAudioEvent. All object calls are asynchronous. That is, audio playback is handled in another thread from the script. The script may continue to run while audio is playing.
Page 15
1 - USB audio 2 - SPDIF audio, stereo PCM 3 - SPDIF audio, raw AC3 4 - analog audio with SPDIF mirroring raw AC3 audio_mode values (Options 0 and 1 only apply to video files; 2 applies to all audio sources) 0 - AC3 Surround 1 - AC3 mixed down to stereo 2 - No audio...
Page 16
audio = CreateObject(“roAudioPlayer”) audio.SetChannelVolumes(&H01, 60) ‘left channel to 60% audio.SetChannelVolumes(&H02, 75) ‘right channel to 75% audio.SetChannelVolumes(&H04, 80) ‘center channel to 80% audio.SetChannelVolumes(&H07, 70) ‘left, right, center channel to 70% audio.SetChannelVolumes(&H3f, 65) ‘all channels to 65% Playing Multiple Audio Files Simultaneously (HD2000 only) Multiple MP3 files along with an audio track as part of a video file can be played to any combination of the following: Analog outputs 1, 2, or 3...
Page 17
MapStereoOutputAux (mapping) • SetVolumeAux (volume) • SetChannelVolumesAux (channel_mask, volume) • The following functions control which specific streams are played SetAudioStream (stream_index) • SetAudioStreamAux (stream_index) • The stream_index is the index of the audio stream within the program stream to be played. A value of -1 indicates that the first audio stream found within the multiplex will be played.
roVideoEvent() and roAudioEvent() Video and Audio events can have one of these integer values. They are declared as separate classes as they are likely to diverge in the future. 0 Undefined Player is in an undefined state. 1 Stopped Playback of the current media item is stopped. 3 Playing The current media item is playing.
This object is used to control and wait for events on the BrightSign generic DB15 control port (HD Compacts) or the DB25 control port and front panel (HD2000). Typically LEDs or Buttons are connected to the DB15 / DB25 port.
roQuadravoxSNS5 This object is used to control and wait for events on the Quadravox SNS5 serial button/LED box. Interfaces: ifSetMessagePort • SetPort(As Object) As Void ifQuadravoxSNS5 – similar to ifGpioControlPort but with the addition of a Flash state • IsInputActive(id As Integer) As Boolean GetWholeState() As Integer SetOutputState(id As Integer, on_state As Boolean, flash_state As Boolean) As Void...
roKeyboard This object is used to wait for events from a USB keyboard. Interfaces: ifSetMessagePort • SetPort(As Object) As Void roKeyboardPress A keyboard event resulting from the user pressing a key on the USB keyboard. The int value is the ASCII code of the key that was pressed.
roIRRemote The key code from Roku’s custom code using the NEC protocol is decoded and sent as an event. Use this object to register your Event port. Interfaces: ifSetMessagePort interface: • SetPort(message_port_object As Object) As Void roIRRemotePress Messages are generated on Roku Soundbridge remote key presses. These have the ifInt interface with the useful function: Interfaces: ifInt –...
roImagePlayer, roImageWidget Display static bitmap images on the video display. Interfaces: ifImageControl • DisplayFile(image_filename As String) As Boolean PreloadFile(filename As String) As Boolean DisplayPreload() As Boolean StopDisplay() As Boolean // removes an image from the display DisplayFileEx(filename As String, mode As Integer, x As Integer, y As Integer) As Boolean PreloadFileEx(filename As String, mode As Integer, x As Integer, y As Integer) As Boolean...
Page 24
12 to 13 - Comb effect vertical and horizontal • 14 - Fade out to background color then back in • 15 - Fade between current image and new image • 16 to 19 - Slides from top, bottom, left and right •...
roInt, roFloat, roString The intrinsic types rotINT32, rotFLOAT, and rotSTRING have an object and interface equivalent. These are useful in the following situations: When an object is needed, instead of a typed value. For example, roList maintains a list of •...
Page 26
BrightScript> l=ListDir("/") BrightScript> for i=1 to l.Count():print l.RemoveHead():next test_movie_3.vob test_movie_4.vob test_movie_1.vob test_movie_2.vob...
However, you will need to provide a cursor bitmap if you want to enable mouse support. There is one you can use in the Roku BrightSign demo which can be downloaded from our web site. To use a touch screen follow these general steps:...
Page 28
GetY() As Integer ifEvent (mouse events). ifEvent has the following member function: GetEvent() As Integer EnableRollover: Use this function to enable a rollover for a touch region. It accepts the touch region’s ID, two strings specifying the names of the on and off bitmap images, a cache setting, and the image player that draws the rollover.
Page 29
v=CreateObject("roVideoPlayer") t=CreateObject("roTouchScreen") p=CreateObject("roMessagePort") v.SetPort(p) t.SetPort(p) v.SetLoopMode(1) v.PlayFile("testclip.mp2v") t.AddRectangleRegion(0,0,100,100,2) loop: msg=wait(0, p) print "type: ";type(msg) print "msg=";msg type(msg)="roTouchEvent" then print "x,y=";msg.GetX();msg.GetY() endif goto loop: Another Example with Mouse support: t=CreateObject("roTouchScreen") t.SetPort(p) REM Puts up a cursor if a mouse is attached REM The cursor must be a 16 x 16 BMP REM The x,y position is the “hot spot”...
roSerialPort This object controls the RS232 serial port, allowing you to receive input and send responses. roSerialPort has these interfaces: 1. ifStream 2. ifSerialControl ifStream has these member functions: SendByte(byte As Integer) As Void SendLine(line As String) As Void SendBlock(block As String) As Void SetEol(eol As String) As Void SetLineEventPort(port As Object) As Void SetByteEventPort(port As Object) As Void...
The roDeviceInfo object implements the ifDeviceInfo interface only. The ifDeviceInfo interface provides: GetModel() As String • Returns the model name for the BrightSign device running the script as a string. For example "HD1010" or "HD2000". GetVersion() As String • Returns the version number of the BrightSign firmware running on the device. For example "1.3.14".
roRegistry () The registry is an area of memory where a small number of persistent settings can be stored. Access to the registry is available through the roRegistry object. This object is created with no parameters. CreateObject("roRegistry") • The following methods are supported: GetSectionList() As roList •...
roSystemTime () roSystemTime provides the ability to read and write the time stored in the RTC This object supports getting and setting the time and time zone. The roSystemTime object implements ifSystemTime. This interface provides: GetLocalDateTime() As ifDateTime • GetUtcDateTime()As ifDateTime •...
NZST: New Zealand Time (Auckland) CHAST: , Fiji Time, , Fiji, Pacific/Fiji, Yankee Time Zone (Fiji) SST: X-ray Time Zone (Pago Pago) GMT: Greenwich Mean Time GMT-1: 1 hour ahead of Greenwich Mean Time GMT-2: 2 hours ahead of Greenwich Mean Time GMT-3: 3 hours ahead of Greenwich Mean Time GMT-4: 4 hours ahead of Greenwich Mean Time GMT-5: 5 hours ahead of Greenwich Mean Time...
SetMillisecond(millisecond As Integer) As Void • AddSeconds(seconds As Integer) As Void • SubtractSeconds(seconds As Integer) As Void • AddMilliseconds(milliseconds As Integer) As Void • SubtractMilliseconds(milliseconds As Integer) As Void • Normalize() As Boolean • Check that all the fields supplied are correct. It fails if values are out of bounds A newly created object is at the time represented by zero seconds.
Page 37
timeout.AddSeconds(30) timer.SetDateTime(timeout) timer.Start() else print "unexpected event received" endif endwhile Example: This code creates a timer that triggers every minute using wildcards in the timer spec. st=CreateObject("roSystemTime") timer=CreateObject("roTimer") mp=CreateObject("roMessagePort") timer.SetPort(mp) timer.SetDate(-1, -1, -1) timer.SetTime(-1, -1, 0, 0) timer.Start() while true ev = wait(0, mp) if (type(ev) = "roTimerEvent") then print "timer event received"...
roReadFile, roCreateFile, roReadWriteFile, roAppendFile () These objects provide file I/O functionality using the ifStreamRead, ifStreamSend, ifStreamSeek, and ifFile interfaces. Creating an roReadFile object opens the specified file for reading only. Object creation fails if the file does not exist. roReadFile implements ifStreamSeek and ifStreamRead. CreateObject("roReadFile", filename As String) •...
Page 39
o Writes the specified characters to the stream. Any null bytes will terminate the block. The ifStreamSeek interface provides: SeekAbsolute(offset As Integer) As Void • o Seeks to the specified offset. If the offset is beyond the end of the file, then the file will be extended upon the next write and any previously unoccupied space will be filled with null bytes.
roTextField () A text field represents an area of the screen that can contain arbitrary text. This feature is intended for presenting diagnostic and usage information rather than for generating a user interface. The roTextField object implements the ifTextField and ifStreamSend interfaces. The object is created with several parameters: CreateObject("roTextField", xpos As Integer, ypos As Integer, •...
Page 41
Write the characters specified at the current cursor position and advance the cursor to one position beyond the last character. SetSendEol(string As String) As Void Set the sequence sent at the end of a SendLine request. This should be left at the default value of chr(13) for normal use.
roAssociativeArray () An associative array (also knows as a map, dictionary or hash table) allows objects to be associated with string keys. The roAssociativeArray class implements the ifAssociativeArray interface. This object is created with no parameters: CreateObject("roAssociativeArray") • The ifAssociativeArray interface provides: AddReplace(key As String, value As Object) As Void •...
roRectangle () This object is created with several parameters: CreateObject("roRectangle", x As Integer, y As Integer, width As • Integer, height As Integer) The interface provides: SetX(x As Integer) As Void • SetY(y As Integer) As Void • SetWidth(width As Integer) As Void •...
roTextWidget () An object used for putting text on the screen. Object creation: CreateObject("roTextWidget", r As roRectangle, line_count As • Integer, text_mode As Integer, pause_time As Integer) r – roRectangle that contains the text line_count – the number of lines of text to show in the rectangle text_mode –...
Page 45
The top 8 bits of the color value are ‘alpha’. Alpha has no effect for the foreground text color but does effect the widget background color. 0 is fully transparent and 255 is fully non-transparent. This feature allows ‘subtitle’ like effects. For example, a semi-transparent black box containing text over video.
roResourceManager () The roResourceManager is used for managing strings in multiple languages. Object creation: CreateObject("roResourceManager", filename As String) • filename = the name of the file that contains all of the localized resource strings required by the user. This file must be in UTF-8 format. The interface includes: SetLanguage(language_identifier As String) As Boolean •...
roClockWidget () roClockWidget puts a clock on the screen. It has no extra interface, only construction arguments. roClockWidget implements the ifTextWidget interface. Object creation: CreateObject("roClockWidget", rect As roRectangle, res As • roResourceManager, display_type As Integer) rect = the rectangle in which the clock is displayed. Based on the size of the rectangle, the widget picks a font.
Page 48
// %y Two digit year // %Y Four digit year // Time format // %H The hour using 24-hour clock (00 to 23) // %I The hour using 12-hour clock (01 to 12) // %k The hour using 24-hour clock (0 to 23); single digits are preceded by a blank.
roUrlTransfer () This object is used for reading from and writing to remote servers through URLs. This object is created with no parameters: CreateObject("roUrlTransfer") • The interface provides: GetIdentity() As Integer • Returns a magic number that can be used to identify whether events originated from this object.
Page 50
AsyncPostFromString(request As String) As Boolean • Use the HTTP POST method to post the supplied string to the current URL. Events of type roUrlEvent will be sent to the message port associated with the object. If false is returned then the request could not be issued and no events will be delivered.
For unexpected errors the return value is negative. There are lots of possible negative errors from the CURL library but it's often best just to look at the text version via GetFailureReason(). Here are some potential errors. Not all of them can be generated by BrightSign: Status Name...
Page 52
CURLE_FTP_COULDNT_USE_REST the REST command failed CURLE_RANGE_ERROR RANGE "command" didn't work CURLE_HTTP_POST_ERROR CURLE_SSL_CONNECT_ERROR wrong when connecting with SSL CURLE_BAD_DOWNLOAD_RESUME couldn't resume download CURLE_FILE_COULDNT_READ_FILE CURLE_LDAP_CANNOT_BIND CURLE_LDAP_SEARCH_FAILED CURLE_FUNCTION_NOT_FOUND CURLE_ABORTED_BY_CALLBACK CURLE_BAD_FUNCTION_ARGUMENT CURLE_INTERFACE_FAILED CURLOPT_INTERFACE failed CURLE_TOO_MANY_REDIRECTS catch endless re-direct loops CURLE_UNKNOWN_TELNET_OPTION User specified an unknown option CURLE_TELNET_OPTION_SYNTAX Malformed telnet option CURLE_PEER_FAILED_VERIFICATION peer's certificate or fingerprint wasn't verified fine...
Page 53
CURLE_CONV_FAILED conversion failed caller must register conversion callbacks using curl_easy_setopt options CURLE_CONV_REQD CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and CURLOPT_CONV_FROM_UTF8_FUNCTION CURLE_SSL_CACERT_BADFILE could not load CACERT file, missing or wrong format CURLE_REMOTE_FILE_NOT_FOUND remote file not found error from the SSH layer, somewhat generic so the error CURLE_SSH message will be of interest when this has happened CURLE_SSL_SHUTDOWN_FAILED...
roRssParser, roRssArticle () roRssParser and roRssArticle class are used to display an RSS ticker on the screen. roRssParser is created with no parameters: CreateObject("roRssParser") • The roRssParser interface provides: ParseFile(filename As String) As Boolean • Parse an RSS feed from a file. ParseString(filename As String) As Boolean •...
roNetworkConfiguration () Object creation: CreateObject("roNetworkConfiguration", 0) • The ifNetworkConfiguration interface provides (methods do not take effect until Apply is called): SetDHCP(key As String, value As Object) As Void • Enable DHCP. Disables all other settings. SetIP4Address(ip As String) As Boolean •...
roStorageInfo () Objects of this type are used to report storage device usage information. Object creation: CreateObject("roStorageInfo", path As String) • Create a roStorageInfo object containing the storage device information for the specified path. The path need not be to the root of the storage device. ifStorageInfo interface: Note that on some filesystems that have a portion of space reserved for the super-user the expression GetUsedInMegabytes() + GetFreeInMegabytes() == GetSizeInMegabytes() may not be true...
• • In addition to looking for autorun.bas scripts, BrightSign looks for autorun.zip files that contain a script name autozip.bas. If autozip.bas is encrypted, then BrightSign uses the password stored in the registry in the section ‘security’ under the name ‘autozipkey’ to decrypt the file. If an autorun.zip file with an autozip.bas file is found and autozip.bas is decrypted, BrightSign will execute the autozip.bas file.
Page 58
t.PushString("Update complete - remove USB drive to restart.") wait: sleep(1000) usb_key = CreateObject("roReadFile", "USB1:/autorun.zip") if type(usb_key) <> "roReadFile" then a=RebootSystem() endif usb_key = 0 goto wait...
Page 59
roDatagramSender, roDatagramReceiver () The roDatagramSender and roDatagramReceiver classes allow for simple sending and receiving of unicast and broadcast UDP packets. roDatagramSender allows UDP packets to be sent to a specified destination. It implements ifDatagramSender. roDatagramSender is created with no parameters: CreateObject("roDatagramSender ") •...
Page 60
roVideoInput() roVideoInput supports playing back video supplied by a video capture dongle. roVideoInput is created with no parameters: CreateObject("roVideoInput ") • The ifVideoInput interface provides: GetStandards() As roArray(String) • GetInputs() As roArray(String) • o These return an array of strings describing the various inputs and video standards that the video capture device supports.
Need help?
Do you have a question about the HD110 and is the answer not in the manual?
Questions and answers