Object Reference Manual (ver 4.7)
2014-06-03
: Brightsign Object Reference Manual (Ver 4.7) Object Reference Manual (ver 4.7) s
Open the PDF directly: View PDF .
Page Count: 284
Download | |
Open PDF In Browser | View PDF |
OBJECT REFERENCE MANUAL Firmware Versions 4.7.x • BrightSign, LLC. 16795 Lark Ave., Suite 200 Los Gatos, CA 95032 | 408-852-9263 | www.brightsign.biz TABLE OF CONTENTS INTRODUCTION .................................................................................................................... 1 INTERFACES AND METHODS OVERVIEW ........................................................................2 Classes .............................................................................................................................................................................. 3 Object and Class Name Syntax ......................................................................................................................................... 3 Zones................................................................................................................................................................................. 3 Event Loops....................................................................................................................................................................... 4 BrightSign Object Library ................................................................................................................................................... 5 BRIGHTSCRIPT CORE OBJECTS .......................................................................................6 roArray ............................................................................................................................................................................... 6 roAssociativeArray ............................................................................................................................................................. 8 roBoolean ........................................................................................................................................................................ 10 roByteArray...................................................................................................................................................................... 11 roDouble, roIntrinsicDouble ............................................................................................................................................. 13 roFunction........................................................................................................................................................................ 14 roGlobal ........................................................................................................................................................................... 15 roInt, roFloat, roString ...................................................................................................................................................... 22 roList ................................................................................................................................................................................ 25 roRegex ........................................................................................................................................................................... 27 roXMLElement ................................................................................................................................................................. 29 roXMLList ........................................................................................................................................................................ 33 PRESENTATION AND WIDGET OBJECTS .......................................................................36 roAudioEventMx .............................................................................................................................................................. 36 roAudioOutput ................................................................................................................................................................. 37 roAudioPlayer .................................................................................................................................................................. 39 roAudioPlayerMx ............................................................................................................................................................. 46 roCanvasWidget .............................................................................................................................................................. 51 roClockWidget ................................................................................................................................................................. 56 roHtmlWidget ................................................................................................................................................................... 59 roImageBuffer .................................................................................................................................................................. 62 roImagePlayer ................................................................................................................................................................. 63 roImageWidget ................................................................................................................................................................ 67 roRectangle ..................................................................................................................................................................... 70 roShoutcastStream .......................................................................................................................................................... 71 roShoutcastStreamEvent ................................................................................................................................................. 72 roTextField....................................................................................................................................................................... 73 roTextWidget ................................................................................................................................................................... 76 roVideoEvent, roAudioEvent............................................................................................................................................ 79 roVideoInput .................................................................................................................................................................... 81 roVideoMode ................................................................................................................................................................... 83 roVideoPlayer .................................................................................................................................................................. 89 roTouchCalibrationEvent ................................................................................................................................................. 96 roTouchEvent .................................................................................................................................................................. 97 roTouchScreen ................................................................................................................................................................ 98 FILE OBJECTS .................................................................................................................104 roAppendFile ................................................................................................................................................................. 104 roCreateFile ................................................................................................................................................................... 106 roReadFile ..................................................................................................................................................................... 108 roReadWriteFile ............................................................................................................................................................. 110 HASHING AND STORAGE OBJECTS .............................................................................112 roBrightPackage ............................................................................................................................................................ 112 roDiskErrorEvent ........................................................................................................................................................... 115 roDiskMonitor ................................................................................................................................................................ 116 roHashGenerator ........................................................................................................................................................... 118 roRegistry ...................................................................................................................................................................... 119 roRegistrySection .......................................................................................................................................................... 120 roSqliteDatabase ........................................................................................................................................................... 122 roSqliteEvent ................................................................................................................................................................. 125 roSqliteStatement .......................................................................................................................................................... 126 roStorageAttached, roStorageDetached ........................................................................................................................ 133 roStorageHotplug .......................................................................................................................................................... 134 roStorageInfo ................................................................................................................................................................. 136 NETWORKING OBJECTS ................................................................................................138 roAssetCollection ........................................................................................................................................................... 138 roAssetFetcher .............................................................................................................................................................. 141 roAssetFetcherEvent ..................................................................................................................................................... 143 roAssetFetcherProgressEvent ....................................................................................................................................... 144 roAssetPool ................................................................................................................................................................... 145 roAssetPoolFiles ............................................................................................................................................................ 147 roAssetRealizer ............................................................................................................................................................. 149 roAssetRealizerEvent .................................................................................................................................................... 151 roDatagramSender, roDatagramReceiver, roDatagramSocket, roDatagramEvent ....................................................... 153 roHttpEvent.................................................................................................................................................................... 158 roHttpServer .................................................................................................................................................................. 160 roMediaStreamer ........................................................................................................................................................... 163 roMediaStreamerEvent .................................................................................................................................................. 165 roMimeStream ............................................................................................................................................................... 166 roMimeStreamEvent ...................................................................................................................................................... 167 roNetworkAdvertisement ............................................................................................................................................... 168 roNetworkAttached, roNetworkDetached....................................................................................................................... 170 roNetworkConfiguration ................................................................................................................................................. 171 roNetworkHotplug .......................................................................................................................................................... 178 roNetworkStatistics ........................................................................................................................................................ 179 roRssParser, roRssArticle ............................................................................................................................................. 181 roRtspStream ................................................................................................................................................................ 183 roRtspStreamEvent ....................................................................................................................................................... 184 roShoutcastStream ........................................................................................................................................................ 185 roShoutcastStreamEvent ............................................................................................................................................... 186 roSnmpAgent................................................................................................................................................................. 187 roSnmpEvent ................................................................................................................................................................. 188 roStreamByteEvent ....................................................................................................................................................... 189 roStreamConnectResultEvent ....................................................................................................................................... 190 roStreamEndEvent ........................................................................................................................................................ 191 roStreamLineEvent ........................................................................................................................................................ 192 roSyncManager ............................................................................................................................................................. 193 roSyncManagerEvent .................................................................................................................................................... 196 roSyncSpec ................................................................................................................................................................... 197 roTCPConnectEvent ...................................................................................................................................................... 199 roTCPServer.................................................................................................................................................................. 200 roTCPStream................................................................................................................................................................. 201 roUrlEvent...................................................................................................................................................................... 203 roUrlStream ................................................................................................................................................................... 207 roUrlTransfer ................................................................................................................................................................. 208 INPUT/OUTPUT OBJECTS ...............................................................................................215 roCecInterface ............................................................................................................................................................... 215 roCecRxFrameEvent, roCecTxCompleteEvent ............................................................................................................. 216 roChannelManager ........................................................................................................................................................ 218 roControlPort ................................................................................................................................................................. 226 roControlUp, roControlDown ......................................................................................................................................... 228 roGpioControlPort, roGpioButton ................................................................................................................................... 229 roIRRemote ................................................................................................................................................................... 231 roIRRemotePress .......................................................................................................................................................... 233 roKeyboard, roKeyboardPress ...................................................................................................................................... 235 roMessagePort .............................................................................................................................................................. 237 roSequenceMatcher ...................................................................................................................................................... 239 roSequenceMatchEvent ................................................................................................................................................ 242 roSerialPort.................................................................................................................................................................... 243 SYSTEM OBJECTS ..........................................................................................................246 roDeviceInfo .................................................................................................................................................................. 246 roResourceManager ...................................................................................................................................................... 249 roSystemLog ................................................................................................................................................................. 251 DATE AND TIME OBJECTS .............................................................................................253 roDateTime .................................................................................................................................................................... 253 roSystemTime ............................................................................................................................................................... 255 roTimer .......................................................................................................................................................................... 259 roTimerEvent ................................................................................................................................................................. 263 roTimeSpan ................................................................................................................................................................... 264 LEGACY OBJECTS ..........................................................................................................265 roSyncPool .................................................................................................................................................................... 265 roSyncPoolEvent ........................................................................................................................................................... 268 roSyncPoolFiles ............................................................................................................................................................. 269 roSyncPoolProgressEvent ............................................................................................................................................. 270 Change Log ......................................................................................................................271 4.4.x, 4.2.x, 3.10.x ......................................................................................................................................................... 271 4.6.x, 4.4.x, 3.10.x ......................................................................................................................................................... 272 4.7.x ............................................................................................................................................................................... 273 INTRODUCTION We use BrightScript Objects (ROs) as the standardized way to expose functionality for our public SDKs. To publish a new API, we create a new BrightScript Object. All BrightSign players use this library of objects. This Object Reference Manual describes the BrightScript Object architecture in two main sections: • • How to use BrightScript Objects (as a script writer) How the initial objects are defined for BrightSign players 1 INTERFACES AND METHODS OVERVIEW Every BrightScript Object consists of one or more "interfaces." An ro interface consists of one or more "methods." For example, the roVideoPlayer object has two interfaces, ifMediaTransport and ifSetMessagePort. The interface ifSetMessagePort has one method, SetPort. Example: p = CreateObject("roMessagePort") video = CreateObject("roVideoPlayer") gpio = CreateObject("roControlPort", "BrightSign") gpio.SetPort(p) video.SetPort(p) This syntax makes use of a shortcut provided by the language: The interface name is optional, unless it is needed to resolve name conflicts. For example: gpio.SetPort(p) is the same as gpio.ifSetMessagePort.SetPort(p) 2 Note: The abstract interface ifSetMessagePort is exposed and implemented by both the roControlPort and the roVideoPlayer objects. Once the SetPort method is called, these objects will send their events to the supplied message port. This is discussed more in the Event Loops section below. BrightScript Objects consist only of interfaces. Interfaces define only methods. There is no concept of a "property" or variable at the object or interface level. These must be implemented as Set/Get methods in an interface. Classes A "class name" is used to create a BrightScript Object. For example: video = CreateObject("roVideoPlayer") The class name of the above BrightScript Object is roVideoPlayer. Object and Class Name Syntax Class names have the following characteristics: • • • • Must start with an alphabetic character (a – z). May consist of alphabetic characters, numbers, or the "_" (i.e. underscore) symbol. Are not case sensitive. May be of any reasonable length. Zones With the BrightSign Zones feature, you can divide the screen into rectangles and play different content in each rectangle. 3 A zone can contain video, images, audio, a clock, or text. There can be only one video zone per screen for all HD and AU models. However, there can be multiple zones of other types on the screen. A text zone can contain simple text strings or can be configured to display an RSS feed in a ticker type display. To enable zone functionality, the following global function must be called in the script: EnableZoneSupport(enable As Boolean) As Void When zones are enabled, the image layer is always on top of the video layer. When zones are not enabled, the image layer is hidden whenever video is played, and the video layer is hidden whenever images are played. Event Loops When writing anything more than a very simple script, an "event loop" will need to be created. Event loops typically have this structure: o Wait for the event. o Process the event. o Return to step 1. An event can be any number occurrences: a button that has been pressed, a timer that has been triggered, or a video that has finished playing back. By convention, BrightScript Object event scripting work as follows. 1. An object of the type roMessagePort is created in BrightScript by the user’s script. 2. Objects 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 all the events go to this one port. To instruct the object to send events to a specific port, use the ifSetMessagePort interface. 4 3. The script waits for an event. The actual function to do this is ifMessagePort.WaitMessage, but if you are using BrightScript, the built-in statement "WAIT" allows you to do this easily. 4. If multiple event types are possible, your script should determine which event the wait received, then process it. The script then jumps back to the wait. An event can be generated by any BrightScript Object. For example, the class roControlPort sends events of type roControlDown and roControlUp. The roControlDown implements the ifInt Interface, which allows access to an integer. An event loop needs to be aware of the possible events it can get and process them. BrightSign Object Library The following chapters specify each of the objects that can be used in BrightScript. A brief description, a list of interfaces, and the member functions of the interfaces are provided for each object class. While most BrightScript objects have self-contained sections in this chapter, some objects are grouped in the same section if they are closely related or depend on one another to function correctly. 5 BRIGHTSCRIPT CORE OBJECTS roArray This object stores objects in a continuous array of memory locations. Since an roArray contains BrightScript components, and there are object wrappers for most intrinsic data types, entries can either be different types or all of the same type. Object creation: CreateObject("roArray", size As Integer, resize As Boolean) • • size: The initial number of elements allocated for an array. resize: If true, the array will be resized larger to accommodate more elements if needed. If the array is large, this process might take some time. • dim: This statement may be used instead of CreateObject to create a new array. Dim is sometimes advantageous because it automatically creates array of array for multi-dimensional arrays. Interfaces: ifArray, ifEnum, ifArrayGet, ifArraySet The ifArray interface provides the following: • • • • • Peek() As Dynamic: Returns the last (highest index) array entry without removing it. Pop() As Dynamic: Returns the last (highest index) entry and removes it from the array. Push(a As Dynamic): Adds a new highest index entry to the end of the array Shift() As Dynamic: Removes index zero from the array and shifts all other entries down by one unit. Unshift(a As Dynamic): Adds a new index zero to the array and shifts all other entries up by one unit. 6 • Delete(a As Integer) As Boolean: Deletes the indicated array entry and shifts all above entries down by one unit. • • • Count() As Integer Returns the index of the highest entry in the array plus one (i.e. the length of the array). Clear(): Deletes every entry in the array. Append(a As Object): Appends one roArray to another. If the passed roArray contains entries that were never set to a value, they are not appended. Note: The two appended objects must be of the same type. The ifEnum interface provides the following: • • • • Reset(): Resets the position to the first element of enumeration. Next() As Dynamic: Returns a typed value at the current position and increment position. IsNext() As Boolean: Returns True if there is a next element. IsEmpty() As Boolean: Returns True if there is not an exact statement. The ifArrayGet interface provides the following: • GetEntry(a As Integer) As Dynamic: Returns an array entry of a given index. Entries start at zero. If an entry that has not been set is fetched, Invalid is returned. The ifArraySet interface provides the following: • SetEntry(a As Integer, b As Dynamic): Sets an entry of a given index to the passed type value. 7 roAssociativeArray An associative array (also known as a map, dictionary, or hash table) that allows objects to be associated with string keys. This object is created with no parameters: CreateObject("roAssociativeArray") Interfaces: ifEnum, ifAssociativeArray The ifEnum interface provides the following: • • • • Reset(): Resets the position to the first element of enumeration. Next() As Dynamic: Returns the typed value at the current position and increment position. IsNext() As Boolean: Returns True if there is a next element. IsEmpty() As Boolean: Returns True if there is not a next element. The ifAssociativeArray interface provides the following: • AddReplace(key As String, value As Object) As Void: Adds a new entry to the array, associating the supplied object with the supplied string. Only one object may be associated with a string, so any existing object is discarded. • Lookup(key As String) As Object: Looks for an object in the array associated with the specified string. If there is no object associated with the string, then an object implementing ifInt and containing zero is returned. • DoesExist(key As String) As Boolean: Looks for an object in the array associated with the specified string. If there is no associated object, then False is returned. If there is such an object, then True is returned. • Delete(key As String) As Boolean: Looks for an object in the array associated with the specified string. If there is such an object, then it is deleted and True is returned. If not, then False is returned. • Clear As Void: Removes all objects from the associative array. 8 • SetModeCaseSensitive(): Makes all subsequent actions case sensitive. All roAssociativeArray lookups are case insensitive by default. • LookupCi(a As String) As Dynamic: Looks for an object in the array associated with the specified string. This method functions similarly to Lookup(), with the exception that key comparisons are always case insensitive, regardless of case mode. • Append(a As Object): Appends a second associative array to the first. Example: aa = CreateObject("roAssociativeArray") aa.AddReplace("Bright", "Sign") aa.AddReplace("TMOL", 42) print aa.Lookup("TMOL") print aa.Lookup("Bright") The above script produces the following: 42 Sign 9 roBoolean This is the object equivalent for the Boolean intrinsic type. It is useful in the following situations: • When an object is needed instead of an intrinsic value. For example, if a Boolean is added to roList, it will be automatically wrapped in an roBoolean object by the language interpreter. When a function that expects a BrightScript component as a parameter is passed a Boolean, BrightScript automatically creates the equivalent BrightScript component. • When any object exposes the ifBoolean interface. That object can then be used in any expression that expects an intrinsic value. Interfaces: ifBoolean The ifBoolean interface provides the following: • • GetBoolean() As Boolean SetBoolean(a As Boolean) 10 roByteArray This object contains functions to convert strings to or from a byte array, as well as to or from ASCII hex or ASCII base 64. Note that if you are converting a byte array to a string, and the byte array contains a zero, the string conversion will end at that point. roByteArray will automatically resize to become larger as needed. If you wish to disable this behavior, use the SetResize() method. If an uninitialized index is read, Invalid is returned. Since roByteArray supports the ifArray interface, it can be accessed with the array [] operator. The byte array is always accessed as unsigned bytes while this interface is being used. This object also supports the ifEnum interface, and so can be used with a "for each" statement. Interfaces: ifByteArray, ifArray, ifArrayGet, ifEnum, ifArraySet See roArray for a description of ifArray, ifArrayGet, ifEnum and ifArraySet. The ifByteArray interface provides the following: • • • • • • • • • WriteFile(filename As String) As Boolean WriteFile(filename As String, start_index As Integer, length As Integer) As Boolean ReadFile(filename As String) As Boolean ReadFile(filename As String, start_index As Integer, length As Integer) As Boolean AppendFile(filename As String) As Boolean SetResize(minimum_allocation_size As Integer, autoresize As Boolean) ToHexString() As String FromHexString(hexstring As String) ToBase64String() As String 11 • • • • • FromBase64String(base65string As String) ToAsciiString() As String FromAsciiString(a As String) GetSignedByte(index As Integer) As Integer GetSignedLong(index As Integer) As Integer: Retreives the integer located at the specified long-word index of the byte array. Note that this method cannot accept a byte index as its parameter. • IsLittleEndianCPU() As Boolean 12 roDouble, roIntrinsicDouble Interfaces: ifDouble The ifDouble interface provides the following: GetDouble() As Double SetDouble(a As Double) 13 roFunction Interfaces: ifFunction • • GetSub() As Function SetSub(value As Function) 14 roGlobal This object provides a set of standard, module-scope functions that are stored in the global object. If one of these global functions is referenced, the compiler directs the runtime to call the appropriate global object member. Note: Global trigonometric functions accept and return values in radians, not degrees. Interfaces: ifGlobal The ifGlobal interface provides the following: • Sleep(milliseconds As Integer): Instructs the script to pause for a specified amount of time without wasting CPU cycles. The sleep interval is specified in milliseconds. • asc(letter As String) As Integer: Returns the ASCII code for the first character of the specified string. A null-string argument will cause an error. • chr(chr As Integer) As String: Returns a one-character string containing a character reflected by the specified ASCII or control. For example, because quotation marks are normally used as string delimiters, you can pass ASCII code 34 to this function to add quotes to a string. • • len(target_string As String) As Integer: Returns the number of characters in a string. str(value As Double) As String: Converts a specified float value to a string. This method also returns a string equal to the character representation of a value. For example, if "A" is assigned a value of 58.5, then calling str(A) will return "58.5" as a string. • • strI(value As Integer) As String: Converts a specified integer value to a string. This method also returns a string equal to the character representation of a value. For example, if "A" is assigned a value of 58.5, then calling stri(A) will return "58" as a string. val(target_string As String) As Double: Returns a number represented by the characters in the string argument. This is the opposite of the str() function. For example, if "A" is assigned the string "58", and "B" is assigned the string "5", then calling val(A+"."+B) will return the float value 58.5. 15 • • abs(x As Double) As Double: Returns the absoule vale of the argument x. atn(x As Double) As Double: Returns the arctangent (in radians) of the argument x (i.e. Atn(x) returns "the angle whose tangent is x"). To get the arctangent in degrees, multiply Atn(x) by 57.29578. • • • csng(x As Integer) As Float: Returns a single-percision float representation of the argument x. cdbl(x As Integer) As Double: Returns a double-percision float representation of the argument x. cint(x As Double) As Integer: Returns an integer representation of the argument x by rounding to the nearest whole number. • cos(x As Double) As Double: Returns the cosine of the arugment x. The argument must be in radians. To obtain the cosine of x when x is in degrees, use Cos(x*.01745329). • • • • exp(x As Double) As Double: Returns the natural exponential of x. This is the inverse of the log() function. fix(x As Double) As Integer: Returns a truncated representation of the argument x. All digits to the right of the decimal point are removed so that the resultant value is an integer. For non-negative values of x, fix(x) is equal to int(x). For negative values of x, fix(x) is equal to int(x)+1. int(x As Double) As Integer: Returns an integer representation of the argument x using the largest whole number that is not greater than the argument. For example, int(2.2) returns 2, while fix(-2.5) returns -3. log(x As Double) As Double: Returns the natural logarithm of the argument x(i.e. loge(x)). This is the inverse of the exp() function. To find the logarithm of a number to a base b, use the following formula: logb(x) = loge(x)/loge(b). • sgn(x As Double) As Integer: Returns an integer representing how the float argument x is signed: -1 for negative, 0 for zero, and 1 for positive. • sgnI(x As Integer) As Integer: Returns an integer representing how the integer argument x is signed: -1 for negative, 0 for zero, and 1 for positive. • sin(x As Double) As Double: Returns the sine of the argument x. The argument must be in radians. To obtain the sine of x when x is in degrees, use sin(x*.01745329). • tan(x As Double) As Double: Returns the tangent of the argument x. The argument must be in radians. To obtain the tangent of x when x is in degrees, use tan(x*.01745329). 16 • sqr(x As Double) As Double: Returns the square root of the argument x. This function is the same as x^(1/2), but calculates the result faster. • Left(target_string As String, n As Integer) As String: Returns the first n characters of the specified string. • Right(target_string As String, n As Integer) As String: Returns the last n characters of the specified string. • StringI(n As Integer, character As Integer) As String: Returns a string composed of a character symbol repeated n times. The character symbol is passed to the method as an ASCII code integer. • String(n As Integer, character As String) As String: Returns a string composed of a character symbol repeated n times. The character symbol is passed to the method as a string. • Mid(target_string As String, start_position As Integer, length As Integer) As String: Returns a substring of the target string. The first integer passed to the method specifies the starting position of the substring, and the second integer specifies the length of the substring. The start position of a string begins with 1. • instr(start_position As Integer, search_text As String, substring_to_find As String) As Integer: Returns the position of a substring within a string. This function is case sensitive and returns 0 if the specified substring is not found. The start position of a string begins with 1. • GetInterface(object As Object, ifname As String) As Interface: Returns a value of the type "Interface". All objects have one or more interfaces. In most cases, you can skip interface specification when calling an object component. This will not cause problems as long as the method names within a function are unique. • Wait(timeout As Integer, port As Object) As Object: Instructs the script to wait on an object that has an ifMessagePort interface. This method will return the event object that was posted to the message port. If the timeout is specified as zero, Wait() will wait indefinitely; otherwise, Wait() will return Invalid after the specified number of milliseconds if no messages have been received. • • ReadAsciiFile(file_path As String) As String: Reads the specified text file and returns it as a string. WriteAsciiFile(file_path As String, buffer As String) As Boolean: Creates a text file at the specified file path. The text of the file is passed as the second parameter. This method cannot be used to edit files: A preexisting text file will be overwritten if it has the same name and directory path as the one being created. 17 Note: The roCreateFile object provides more flexibility if you need to create or edit files. • ListDir(path As String) As Object: Returns an roList containing the contents of the specified directory path. File names are converted to all lowercase. • MatchFiles(path As String, pattern_in As String) As Object: Takes a directory to look in (it can be as simple as "." or "/") and a pattern to be matched and then returns an roList containing the results. Each listed result contains only the part of the filename that is matched against the pattern, not the full path. The match is only applied in the specified directory; you will get no results if the pattern contains a directory separator. The pattern is case insensitive. It may contain the following special characters: o ? -- Matches any single character. o * -- Matches zero or more arbitrary characters. o […]-- Matches any single character specified within the brackets. The closing bracket is treated as a member of the character class if it immediately follows the opening bracket (i.e. "[]]" matches a single closed bracket). Within this class, "-" can be used to specify a range unless it is the first or last character (e.g. "[ACf-h"] is equivalent to "[ABCfgh]"). A character class may be negated by specifying "^" as the first character. To match a literal of this character, place it elsewhere in the class. • • • Note: The "?", "*", and "[" lose their function if preceded by a single "\", and a single"\" can be matched as "\\". LCase(target_string As String) As String: Converts the specified string to all lower case. UCase(target_string As String) As String: Converts the specified string to all upper case. DeleteFile(file_path As String) As Boolean: Deletes the file at the specified file path. This method returns False if the delete fails or if the file does not exist. • DeleteDirectory(diretory As String) As Boolean: Deletes the specified directory. This method will recursively delete any files and directories that are necessary for removing the specified directory. This method returns False if it fails to delete the directory, but it may still delete some of the nested files or directories. • CreateDirectory(directory As String) As Boolean: Creates the specified directory. Only one directory can be created at a time. This method returns True upon success and False upon failure. • • RebootSystem(): Causes a soft reboot. ShutdownSystem() 18 • • UpTime(dummy As Integer) As Float: Returns the uptime of the system (in seconds) since the last reboot. FormatDrive(drive As String, fs_type As String) As Boolean: Formats the specified drive using one of the file systems listed below. This function returns True upon success and False upon failure: o vfat (DOS/Windows file system): Readable and writable by Windows, Linux, and MacOS. o ext2 (Linux file system): Writable by Linux and readable by Windows and MacOS with additional software. o ext3 (Linux file system): Writable by Linux and readable by Windows and MacOS with additional software. This file system uses journaling for additional reliability. • EjectDrive(drive As String) As Boolean: Ejects the specified drive (e.g. "SD:") and returns True if successful. If the script is currently accessing files from the specified drive, the ejection process will fail. • CopyFile(source As String, destination As String) As Boolean: Copies the file at the specified source file-path name to the specified destination file-path name. The function returns True if successful and False in the event of failure. • MoveFile(a As String, b As String) As Boolean: Moves the specified source file to the specified destination. The function returns True if successful and False in the event of failure. Note: Both path names must be on the same drive. • strtoi(target_string As String) As Integer: Converts the target string to an integer. Any non-integer characters (including decimal points and spaces), and any numbers to the right of a non-integer character, will not be part of the integer output. • • • • • • rnd(a As Dynamic) As Dynamic RunGarbageCollector() As Object GetDefaultDrive() As String: Returns the current default drive complete with a trailing slash. When running autorun.brs, the drive containing the autorun is designated as the current default. SetDefaultDrive(a As String): Sets the current default drive, which does not need to include a trailing slash. This function will not fail. However, if the specified default drive is non-existent, it will not be possible to retrieve anything. EnableZoneSupport(a As Boolean) EnableAudioMixer(a As Boolean) 19 • • Pi() As Double: Returns the value of pi as a double-precision floating-point number. ParseJson(JSON_string as String) As Object: Parses a string formatted according to the RFC4627 standard and returns an equivalent BrightScript object, which can consist of the following: Booleans, integers, floating point numbers, strings, roArray objects, and roAssociativeArray objects. The ParseJson() method has the following properties: o Invalid will be returned if the string is not syntactically correct. o Any roAssociativeArray objects that are returned will be case sensitive. o An error will be returned if an roArray or roAssociativeArray is nested more than 256 levels deep. Example: The following script demonstrates how to use ParseJson() to process a JSON object containing the titles and URLs of a set of images. JSON Script { "photos" : [ { }, { }, { ] } "title" : "View from the hotel", "url" : "http://example.com/images/00012.jpg" "title" : "Relaxing at the beach", "url" : "http://example.com/images/00222.jpg" "title" : "Flat tire", "url" : "http://example.com/images/00314.jpg" 20 } BrightScript searchRequest = CreateObject("roUrlTransfer") searchRequest.SetURL("http://api.example.com/services/rest/getPhotos") response = ParseJson(searchRequest.GetToString()) For Each photo In response.photos GetImage(photo.title, photo.url) End For 21 roInt, roFloat, roString The intrinsic types roInt32, roFloat, and roString have an object and interface equivalent. These are useful in the following situations: • • An object is needed instead of a typed value. For example, roList maintains a list of objects. If any object exposes the ifInt, ifFloat, or ifString interfaces, that object can be used in any expression that expects a typed value. For example, an roTouchEvent can be used as an integer whose value is the userid of the roTouchEvent. Note: If "o" is an roInt, then these statements have the following effects: o print o: Prints o.GetInt() o i%=o: Assigns the integer i% the value of o.GetInt() o k=o: Presumably k is typeOmatic, so it becomes another reference to the roInt o o o=5: This is NOT the same as o.SetInt(5). Instead it releases o, changes the type of o to roINT32 (o is typeOmatic), and assigns it to 5. When a function that expects a BrightScript Object as a parameter is passed an int, float, or string, BrightScript automatically creates the equivalent object. Interfaces: ifInt, ifIntOps, ifFloat, ifString, ifStringOps roInt contains the ifInt interface, which provides the following: • • GetInt() As Integer SetInt(value As Integer) As Void 22 roInt also contains the ifIntOps interface, which provides the following: • ToStr() As String roFloat contains the ifFloat interface, which provides the following: • • GetFloat() As Float SetFloat(value As Float) As Void roString contains the ifString interface, which provides the following: • • GetString() As String SetString(value As String) As Void roString also contains the ifStringOps interface, which provides the following: • • • • • • • • • • • • • • SetString(a As String, b As Integer) AppendString(a As String, b As Integer) Len() As Integer GetEntityEncode() As String Tokenize(a As String) As Object Trim() As String ToInt() As Integer ToFloat() As Float Left(a As Integer) As String Right(a As Integer) As String Mid(a As Integer) As String Mid(a As Integer, b As Integer) As String Instr(a As String) As Integer Instr(a As Integer, b As String) As Integer 23 Example: BrightScript> BrightScript> BrightScript> 555 BrightScript> 555 BrightScript> 500 o=CreateObject("roInt") o.SetInt(555) print o print o.GetInt() print o-55 Example: BrightScript> list=CreateObject("roList") BrightScript> list.AddTail(5) BrightScript> print type(list.GetTail()) An integer value of "5" is converted to type roInt automatically because list.AddTail expects a BrightScript Object as its parameter. Example: Here the function ListDir returns an object roList of roStrings: 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 24 roList This object functions as a general-purpose, doubly linked list. It can be used as a container for arbitrary-length lists of BrightSign Objects. The array operator [ ] can be used to access any element in an ordered list. Interfaces: ifList, ifEnum, ifArray, ifArrayGet, ifArraySet The ifList interface provides the following: • • • • • Count() As Integer: Returns the number of elements in the list. ResetIndex() As Boolean: Resets the current index or position in the list to the head element. AddTail(obj As Object) As Void: Adds a typed value to the tail of the list. AddHead(obj As Object) As Void: Adds a typed value to the head of the list. RemoveIndex() As Object: Removes an entry from the list at the current index or position and increments the index or position in the list. It returns Invalid when the end of the list is reached. • GetIndex() As Object: Retrieves an entry from the list at the current index or position and increments the index or position in the list. It returns Invalid when the end of the list is reached. • • • • • RemoveTail() As Object: Removes the entry at the tail of the list. RemoveHead() As Object: Removes the entry at the head of the list. GetTail() As Object: Retrieves the entry at the tail of the list and keeps the entry in the list. GetHead() As Object: Retrieves the entry at the head of the list and keeps the entry in the list. Clear(): Removes all elements from the list. The ifEnum interface provides the following: • • • • Reset(): Resets the position to the first element of enumeration. Next() As Dynamic: Returns the typed value at the current position and increment position. IsNext() As Boolean: Returns True if there is a next element. IsEmpty() As Boolean: Returns True if there is not a next element. 25 The ifArray interface provides the following: • • • • • • Peek() As Dynamic: Returns the last (highest index) array entry without removing it. Pop() As Dynamic: Returns the last (highest index) entry and removes it from the array. Push(a As Dynamic): Adds a new highest index entry to the end of the array Shift() As Dynamic: Removes index zero from the array and shifts all other entries down by one unit. Unshift(a As Dynamic): Adds a new index zero to the array and shifts all other entries up by one unit. Delete(a As Integer) As Boolean: Deletes the indicated array entry and shifts all above entries down by one unit. • • • Count() As Integer Returns the index of the highest entry in the array plus one (i.e. the length of the array). Clear(): Deletes every entry in the array. Append(a As Object): Appends one roArray to another. If the passed roArray contains entries that were never set to a value, they are not appended. Note: The two appended objects must be of the same type. The ifArrayGet interface provides the following: • GetEntry(a As Integer) As Dynamic: Returns an array entry of a given index. Entries start at zero. If an entry that has not been set is fetched, Invalid is returned. The ifArraySet interface provides the following: • SetEntry(a As Integer, b As Dynamic): Sets an entry of a given index to the passed type value. 26 roRegex This object allows the implementation of the regular-expression processing provided by the PCRE library. This object is created with a string to represent the "matching-pattern" and a string to indicate flags that modify the behavior of one or more matching operations: CreateObject("roRegex", "[a-z]+", "i") The match string (in the example above, "[a-z]+", which matches all lowercase letters) can include most Perl compatible regular expressions found in the PCRE documentation. This object supports any combination of the following behavior flags (in the example above, "i", which can be modified to match both uppercase and lowercase letters): • • • • "i": Case-insensitive match mode. "m": Multiline mode. The start-line ("^") and end-line ("$") constructs match immediately before or after any newline in the subject string. They also match at the absolute beginning or end of a string. "s": Dot-all mode, which includes a newline in the ".*" regular expression. This modifier is equivalent to "/s" in Perl. "x": Extended mode, which ignores whitespace characters except when escaped or inside a character class. This modifier is equivalent to "/x" in Perl. Interfaces: ifRegex The ifRegex interface provides the following: • IsMatch(a As String) As Boolean: Returns True if the string is consistent with the matching pattern. 27 • Match(a As String) As roArray: Returns an roArray of matched substrings from the string. The entire match is returned in the form array[0].This will be the only entry in the array if there are no parenthetical substrings. If the matching pattern contains parenthetical substrings, the relevant substrings will be returned as an array of length n+1, where array[0] is the entire match and each additional entry in the array is the match for the corresponding parenthetical expression. • Replace(a As String, b As String) As String: Replaces the first occurrence of a match to the matching pattern in the string with the subset. The subset may contain numbered back-references to parenthetical substrings. • • ReplaceAll(a As String, b As String) As String: Performs a global search and replace. Split(a As String) As roList: Uses the matching pattern as a delimiter and splits the string on the delimiter boundaries. The function returns an roList of strings that were separated by the matching pattern in the original string. 28 roXMLElement This object is used to contain an XML tree. The roXMLElement object is created with no parameters: CreateObject("roXMLElement") The following examples illustrate how XML elements are parsed in BrightScript:This is example text Name = tag1 Attributes = Invalid Body = roString containing "This is example text"Name = tag2 Attributes = roAssociativeArray with one entry, {caveman, barney} Body = Invalid If the tag contains other tags, the body will be of the type roXMLList. To generate XML content, create an roXMLElement and call the SetBody() and SetName() methods to build it. Then call the GenXML() method to generate it. See the following example: 29 root.SetName("myroot") root.AddAttribute("key1","value1") root.AddAttribute("key2","value2") ne=root.AddBodyElement() ne.SetName("sub") ne.SetBody("this is the sub1 text") ne=root.AddBodyElement() ne.SetName("subelement2") ne.SetBody("more sub text") ne.AddAttribute("k","v") ne=root.AddElement("subelement3") ne.SetBody("more sub text 3") root.AddElementWithBody("sub","another sub (#4)") PrintXML(root, 0) print root.GenXML(false) Interfaces: ifXMLElement The ifXMLElement interface provides the following: • • • • • • • GetBody() As Object GetAttributes() As Object GetName() As String GetText() As String GetChildElements() As Object GetNamedElements(a As String) As Object GetNamedElementsCi(a As String) As Object 30 • SetBody(a As Object): Generates an roXMLList for the body if needed. The method then adds the passed item (which should be an roXMLElement tag). • • • • • • AddBodyElement() As Object AddElement(a As String) As Object AddElementWithBody(a As String, b As Object) As Object AddAttribute(a As String, b As String) SetName(a As String) Parse(a As String) As Boolean: Parses the XML content passed to it. In the event of failure, this method returns False. However, it also populates roXMLElement with whatever text could be successfully parsed. To avoid passing along erroneous strings, it is always best to have the script check the return value of Parse() before using them. • • • • • • GenXML(a As Object) As String: Generates XML content. This method takes a single Boolean parameter, indicating whether or not the XML should have an tag at the top. Clear() GenXMLHdr(a As String) As String IsName(a As String) As Boolean HasAttribute(a As String) As Boolean ParseFile(a As String) As Boolean The following is an example subroutine to print out the contents of an roXMLElement tree: PrintXML(root, 0) Sub PrintXML(element As Object, depth As Integer) print tab(depth*3);"Name: ";element.GetName() if not element.GetAttributes().IsEmpty() then print tab(depth*3);"Attributes: "; for each a in element.GetAttributes() 31 print a;"=";left(element.GetAttributes()[a], 20); if element.GetAttributes().IsNext() then print ", "; end for print end if if element.GetText()<>invalid then print tab(depth*3);"Contains Text: ";left(element.GetText(), 40) end if if element.GetChildElements()<>invalid print tab(depth*3);"Contains roXMLList:" for each e in element.GetChildElements() PrintXML(e, depth+1) end for end if print end sub 32 roXMLList Interfaces: ifList, ifEnum, ifArray, ifArrayGet, ifArraySet, ifXMLList The ifList interface provides the following: • • • • • GetHead() As Dynamic: Retrieves the entry at the head of the list and keeps the entry in the list. GetTail() As Dynamic: Retrieves the entry at the tail of the list and keeps the entry in the list. RemoveHead() As Dynamic: Removes the entry at the head of the list. RemoveTail() As Dynamic: Removes the entry at the tail of the list. GetIndex() As Dynamic: Retrieves an entry from the list at the current index or position and increments the index or position in the list. It returns Invalid when the end of the list is reached. • RemoveIndex() As Dynamic: Removes an entry from the list at the current index or position and increments the index or position in the list. It returns Invalid when the end of the list is reached. • • • • • AddHead(a As Dynamic): Adds a typed value to the head of the list. AddTail(a As Dynamic): Adds a typed value to the tail of the list. ResetIndex() As Boolean: Resets the current index or position in the list to the head element. Count() As Integer: Returns the number of elements in the list. Clear(): Removes all elements from the list. The ifEnum interface provides the following: • • • • Reset(): Resets the position to the first element of enumeration. Next() As Dynamic: Returns the typed value at the current position and increment position. IsNext() As Boolean: Returns True if there is a next element. IsEmpty() As Boolean: Returns True if there is not a next element. 33 The ifArray interface provides the following: • • • • • • Peek() As Dynamic: Returns the last (highest index) array entry without removing it. Pop() As Dynamic: Returns the last (highest index) entry and removes it from the array. Push(a As Dynamic): Adds a new highest index entry to the end of the array Shift() As Dynamic: Removes index zero from the array and shifts all other entries down by one unit. Unshift(a As Dynamic): Adds a new index zero to the array and shifts all other entries up by one unit. Delete(a As Integer) As Boolean: Deletes the indicated array entry and shifts all above entries down by one unit. • • • Count() As Integer Returns the index of the highest entry in the array plus one (i.e. the length of the array). Clear(): Deletes every entry in the array. Append(a As Object): Appends one roArray to another. If the passed roArray contains entries that were never set to a value, they are not appended. Note: The two appended objects must be of the same type. The ifArrayGet interface provides the following: • GetEntry(a As Integer) As Dynamic: Returns an array entry of a given index. Entries start at zero. If an entry that has not been set is fetched, Invalid is returned. The ifArraySet interface provides the following: • SetEntry(a As Integer, b As Dynamic): Sets an entry of a given index to the passed type value. The ifXMLList interface provides the following: • • • GetAttributes() As Object GetText() As String GetChildElements() As Object 34 • GetNamedElements(a As String) As Object: Returns a new XMLList that contains all roXmlElements that match the name of the passed element. This action is the same as using the dot operator on an roXmlList. • • GetNamedElementsCi(a As String) As Object Simplify() As Object: Returns an roXmlElement if the list contains exactly one element. Otherwise, it will return itself. 35 PRESENTATION AND WIDGET OBJECTS roAudioEventMx The roAudioPlayerMx object can generate roAudioEventMx messages with the following values: • • • • 8 EVENT_MEDIAENDED 14 EVENT_OVERLAY_MEDIAENDED 16 EVENT_MEDIAERROR 17 EVENT_OVERLAY_MEDIAERROR "Media ended" events are sent when a track finishes and there are no more queued tracks for the player, while "Media error" events are sent when a queued file is not found (e.g. when it does not exist). Interfaces: ifInt, ifSourceIdentity, ifAudioUserData The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifSourceIdentity interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity() As Integer The ifAudioUserData interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity() As Integer 36 roAudioOutput This object allows individual control of audio outputs on the player. Object Creation: roAudioOutput requires a single output parameter upon creation. CreateObject("roAudioOutput", output As String) The audio output parameter can take the following strings: • Analog • SPDIF • HDMI • USB • NONE These strings can be extended if future BrightSign players have multiple channels of the same type of audio output. For example, Analog could be extended to Analog:1 or Analog:0-2. You can create any number of roAudioOutput objects. There can be multiple instances of this object that represent the same audio output, but in these cases one object will override another. Interfaces: ifAudioOutput The ifAudioOuput interface provides the following: • SetVolume(a As Integer) As Boolean: Sets the volume of the specified output as a percentage represented by an integer between 0 and 100. • SetMute(a As Boolean) As Boolean: Mutes the specified output if True. This method is set to False by default. 37 GetOutput() As String: Returns the string with which the roAudioOutput object was created. SetAudioDelay(delay_in_milliseconds As Integer) As Boolean: Delays the audio for a specific audio ouput by lagging decoded samples before they reach that output. Delays are limited to 150ms or less. Currently, the system software only supports positive delays; therefore, if you need to set the audio ahead of the video, you will need to use SetVideoDelay() instead. The SetVolume and SetMute methods work in conjunction with the volume and mute functionality offered by • • roAudioPlayer. The roAudioPlayer volume settings affect the audio decoder volume. The audio stream is then sent to the assigned outputs, which have an additional level of volume control enabled by roAudioOutput. Note: To control which audio outputs connect to audio player outputs generated by roAudioOutput, use the SetPcmAudioOutputs and SetCompressedAudioOutputs methods, which can be used for roVideoPlayer and roAudioPlayer. See the roAudioPlayer entry for further explanation of these methods. The roAudioOutput object affects the absolute volume (as well as mute settings) for an audio output. If two players are streaming to the same output, both will be affected by any settings implemented through roAudioOutput. 38 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 the type roAudioEvent. All object calls are asynchronous. In other words, audio playback is handled in a different thread from the script. The script may continue to run while audio is playing. Interfaces: ifIdentity, ifSetMessagePort, ifMediaTransport, ifAudioControl. The ifIdentity interface provides the following: • GetIdentity() As Integer The ifSetMessagePort interface provides the following: • • SetPort(As Object) As Void SetPort(a As Object) See roVideoPlayer for a description of ifMediaTransport. The ifAudioControl interface provides the following: • SetPcmAudioOutputs(array As Object) As Boolean: Determines which PCM audio outputs are connected to audio player outputs generated by roAudioOutput. This method takes as its argument one or more outputs in the form of an roArray of roAudioOutput parameters. • SetCompressedAudioOutputs(array As Object) As Boolean: Determines which compressed audio outputs are connected to audio player outputs generated by roAudioOutput. This method takes as its argument one or more outputs in the form of an roArray of roAudioOutput parameters. Note: When one or both of these output methods are called, they will override the settings of the following ifAudioControl methods: SetAudioOutput(), MapStereoOutput(), SetUsbAudioPort(), MapDigitalOutput(). 39 • SetMultichannelAudioOutputs(array As Object) As Boolean: • SetAudioOutput(audio_output As Integer) As Boolean • SetAudioMode(audio_mode As Integer) As Boolean • MapStereoOutput(mapping As Integer) As Boolean • MapDigitalOutput(mapping As Integer) As Boolean Note: MapDigitalOutput is not available on the HD2000. • • • • • • • • • • • SetVolume(volume As Integer) As Boolean SetChannelVolumes(channel_mask As Integer, volume As Integer) As Boolean SetUsbAudioPort(a As Integer) As Boolean SetSpdifMute(a As Boolean) As Boolean StoreEncryptionKey(a As String, b As String) As Boolean StoreObfuscatedEncryptionKey(a As String, b As String) As Boolean SetStereoMappingSpan(a As Integer) As Boolean ConfigureAudioResources() As Boolean SetAudioStream(stream_index As Integer) As Boolean SetAudioDelay(delay_in_milliseconds As Integer) As Boolean: Adds a presentation time stamp (PTS) offset to the audio. This makes it possible to adjust for file multiplexing differences. Delays are limited to 150ms or less. Currently, the system software only supports positive delays; therefore, if you need to set the audio ahead of the video, you will need to use SetVideoDelay() instead. SetVideoDelay(delay_in_milliseconds As Integer) As Boolean: Adds a presentation time stamp (PTS) offset to the video. This makes it possible to adjust for file multiplexing differences. Delays are limited to 150ms or less. Note: The following "Aux" functions are implemented only on the HD2000 • SetAudioOutputAux(audio_output As Integer) As Boolean • SetAudioModeAux(audio_mode As Integer) As Boolean • MapStereoOutputAux(mapping As Integer) As BooleanSetVolumeAux(volume As Integer) As Boolean 40 • • SetChannelVolumesAux(channel_mask As Integer, volume As Integer) As Boolean SetAudioStreamAux(stream_index As Integer) As Boolean A call to video.Stop is needed before changing the audio output when a video file is playing or has played. Example: This example shows how to use the SetPcmAudioOutputs and SetCompressedAudioOutputs methods in conjunction with roAudioOutput. The video player is configured to output decoded audio to the analog output or compressed audio to the HDMI and SPDIF outputs. ao1=CreateObject("roAudioOutput", "Analog") ao2=CreateObject("roAudioOutput", "HDMI") ao3=CreateObject("roAudioOutput", "SPDIF") v1=CreateObject("roVideoPlayer") v1.SetPcmAudioOutputs(ao1) --or-ar = CreateObject("roArray", 2, true) ar[0] = ao2 ar[1] = ao3 v1.SetCompressedAudioOutputs(ar) Note: In most cases, rerouting audio outputs during audio/video playback will cause playback to stop. The system software will still be responsive, so you can use commands to exit playback during or following an audio output modification. 41 audio_output values 0 – Analog audio 1 – USB audio 2 – Digital audio, stereo PCM 3 – Digital audio, raw AC3 4 – Onboard analog audio with HDMI mirroring raw AC3 digital audio values 0 – Onboard HDMI 1 – SPDIF from expansion module audio_mode values: Options 0 and 1 only apply to video files; while 2 applies to all audio sources. 0 – AC3 Surround 1 – AC3 mixed down to stereo 2 – No audio 3 – Left 4 – Right mapping values: Used to select which analog output to use if audio_output is set to 0. 0 – Stereo audio is mapped to onboard analog output 1 – Stereo audio is mapped to expansion module leftmost output 2 – Stereo audio is mapped to expansion module middle output 3 – Stereo audio is mapped to expansion module rightmost output 42 set_volume: Volume functions as a percentage and therefore takes a value between 0-100. The volume value is clipped prior to use (i.e. SetVoume(101) will set the volume to 100 and return True). The volume is the same for all mapped outputs and USB/SPDIF/analog. Note: Separate volume levels are stored for roAudioPlayer and roVideoPlayer. set_channel_volumes: You can control the volume of individual audio channels. This volume command takes a hex channel mask, which determines the channels to apply the volume to, and a level, which is a percentage of the full scale. The volume control works according to audio channel rather than the output. The channel mask is a bit mask with the following bits for MP3 output: • • • &H01 Left &H02 Right &H03 Both left and right Example: This code sets audio output to the rightmost expansion moduleaudio port. video = CreateObject("roVideoPlayer") video.SetAudioOutput(0) video.MapStereoOutput(3) Example: This code sets the volume level for individual channels. audio = CreateObject("roAudioPlayer") audio.SetChannelVolumes(&H01, 60) audio.SetChannelVolumes(&H02, 75) ‘left channel to 60% ‘right channel to 75% 43 audio.SetChannelVolumes(&H03, 65) ‘all channels to 65% Playing Multiple Audio Files Simultaneously Multiple MP3 files, as well as the audio track of a video file, can be played to any combination of the following: • • • Analog outputs SPDIF / HDMI USB Only a single file can be sent to an output at any given time. For example, two roAudioPlayers cannot simultaneously play to the SPDIF output. The second one to attempt a PlayFile will get an error. To free an output, the audio or video stream must be stopped (using the ifMediaTransport Stop or StopClear calls). Notes on multiple audio-file functionality: • The onboard analog audio output and HDMI output are clocked by the same sample-rate clock. Therefore, if different content is being played out of each, the content must have the same sample rate. • • Currently, only a single set of USB speakers is supported. Each audio and video stream played consumes some of the finite CPU resources. The amount consumed depends on the bitrates of the streams. Testing is the only way to determine whether a given set of audio files can be played at the same time as a video. The maximum recommended usage is a 16Mbps video file with three simultaneous MP3 160kbps streams. Example: This code plays a video with audio over HDMI and an MP3 file to the onboard analog port. video=CreateObject("roVideoPlayer") 44 video.SetAudioOutput(3) video.PlayFile("video.mpg") audio=CreateObject("roAudioPlayer") audio.MapStereoOutput(0) audio.PlayFile("audio.mp3") 45 roAudioPlayerMx This object allows you to mix audio files. Each roAudioPlayerMx object conatins two internal audio players: The main audio playlist consists of queued audio tracks that play sequentially, while the audio overlay plays files on top of the main playlist. A fade will not occur if it is called while an overlay is playing, but the next audio track will start playing as expected. Tracks are queued to PlayFile with their fade parameters specified in an associative array. These are the parameters you can pass to PlayFile: • • Filename: The filename of the track FrontPorch: The length, in milliseconds (ms), to skip from the start of the track. This value is 0 by default. • FadeOutLocation: The location, in milliseconds (ms), of the fade out relative to the value of the FrontPorch. If the value is 0 (which is the default setting), and the FadeOutLength has a non-zero value, then the fade out is calculated back from the end of the file. • • FadeOutLength: The length of the fade out in milliseconds (ms). This value is 0 by default. SegueLocation: The location, in milliseconds (ms), of the event that triggers the next audio file to play. This location is relative to the first audio file that is played. If the SegueLocation parameter is not passed to PlayFile, the value defaults to the FadeOutLocation. • BackPorchLocation: The location, in milliseconds (ms), of the termination point for the audio track. This location is relative to the first audio file that is played. If the BackPorchLocation parameter is not passed to PlayFile, the audio file plays to the end. The value is 0 by default, which disables the back porch. • TrackVolume: The relative volume of of the audio track, measured as a percentage. Specify the percentage using values between 0 and 100. • • • EventID: The ID for an audio event EventTimeStamp: The timestamp for the audio event. There can only be one event per audio file. QueueNext: The queuing of an audio track. Set the parameter value to 1 to queue an audio file to play after the current track. 46 • Overlay: The overlay specification of an audio track. Set the parameter value to 1 to fade down the main audio playlist while playing the audio track as an overaly. Overlays have additional parameters: o AudioBedLevel: The volume-level percentage of the main audio playlist while the overlay is playing. Specify the percentage using values between 0 and 100. o AudioBedFadeOutLength: The fade-out length of the main audio playlist. o AudioBedFadeInLength: The fade-in lenth for the length of the underlying audio track once the segue is triggered. • FadeCurrentPlayNext: A fade command. Set the parameter value to 1 to fade out the current main audio playlist track and fade in the designated audio file. • CrossfadeCurrentPlayNext: A crossfade command. Set the parameter value to 1 to force an immediate crossfade between the current main audio playlist track and the designated audio file. • UserString: A string that can be set to a unique value for each roAudioPlayerMx instance. This string is returned with every event generated by the instance. Since all current platforms can support multiple roAudioPlayerMx instances running at the same time, the UserString allows the script to distinguish between event returns. The following diagram illustrates how some of these timing parameters work together: 47 Example: The following example illustrates a simple crossfade between audio tracks. a = CreateObject("roAudioPlayerMx") track1 = CreateObject("roAssociativeArray") track1["Filename"] = "file1.mp3" track1["FadeInLength"] = 4000 track1["FadeOutLength"] = 4000 track1["QueueNext"] = 1 track2 = CreateObject("roAssociativeArray") track2["Filename"] = "file2.mp3" track2["FadeInLength"] = 4000 track2["FadeOutLength"] = 4000 track2["QueueNext"] = 1 a.PlayFile(track1) a.PlayFile(track2) Interfaces: ifMediaTransport, ifSetMessagePort, ifAudioControl, ifSetMessagePort, ifAudioControlMx The ifMediaTransport interface provides the following: • • • • • PlayFile(a As Object) As Boolean Stop() As Boolean Play() As Boolean Pause() As Boolean Resume() As Boolean 48 • • SetLoopMode(a As Boolean) As Boolean GetPlaybackStatus() As Object The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifAudioControl interface provides the following: • • • • • • • • • • • • • • • MapStereoOutput(a As Integer) As Boolean SetVolume(a As Integer) As Boolean SetChannelVolumes(a As Integer, b As Integer) As Boolean SetAudioOutput(a As Integer) As Boolean SetAudioMode(a As Integer) As Boolean SetAudioStream(a As Integer) As Boolean SetUsbAudioPort(a As Integer) As Boolean SetSpdifMute(a As Boolean) As Boolean MapDigitalOutput(a As Integer) As Boolean StoreEncryptionKey(a As String, b As String) As Boolean StoreObfuscatedEncryptionKey(a As String, b As String) As Boolean SetStereoMappingSpan(a As Integer) As Boolean ConfigureAudioResources() As Boolean SetPcmAudioOutputs(a As Object) As Boolean SetCompressedAudioOutputs(a As Object) As Boolean The ifIdentity interface provides the following: • GetIdentity() As Integer The ifAudioControlMx interface provides the following: 49 • SetDecoderCount(a As Integer) As Boolean 50 roCanvasWidget This object composites background color, text, and images into a single rectangle, allowing you to layer images on a zaxis. Like any other widget, roCanvasWidget is created with an roRectangle to set its size and position on the screen. Interfaces: ifCanvasWidget The ifCanvasWidget interface provides the following: • Hide(): Hides the widget. • Show(): Shows the widget. • SetLayer(object content, int z-level): Sets the contents of a layer within the widget. The lowest zlevel is drawn first, and the highest z-level is drawn last. The object content is described below. • ClearLayer(int z-level): Clears the specified layer. • Clear(): Clears all of the layers. • EnableAutoRedraw(bool enable): Enables or disables the automatic redrawing of the widget. o When this function is enabled, each call to SetLayer, ClearLayer, or Clear results in a redraw. If you need to change multiple layers, then you should disable auto redraw while calling the SetLayer function. o SetLayer enables or disables redrawing of the widget when layer content is changed. When auto-redraw is enabled, each call to SetLayer, ClearLayer, or Clear results in a redraw. To batch multiple updates together, you should first suspend drawing using EnableAutoRedraw(false), then make the changes to the content, and finally re-enable drawing using EnableAutoRedraw(true). The redraw happens in a separate thread, so EnableAutoRedraw returns almost immediately. 51 Object Content The content specified in each layer can consist of one or more objects. Each object is defined by an roAssociativeArray. If there is more than one object, then each is placed into an roArray prior to passing to the SetLayer function. Currently, there are four object types: 1. Background color • color: The #[aa]rrggbb hex value of the background color • targetRect: A target rectangle, which is another roAssociativeArray consisting of x, y, w, and h values. These values are relative to the top left corner of the widget. 2. Text • text: A string of text to display • targetRect: The rectangle in which the text is displayed • textAttrs: An roAssociativeArray containing attributes to be applied to the text. The attributes can be any of the following: o font: Small/medium/large/huge o fontSize: A point size that is used directly when creating the font. If the value is set to 0, then the font automatically resizes to fit the targetRect. o fontfile: The filename for a non-system font to use o hAlign: The left/center/right alignment of the text on a line o vAlign: The top/center/bottom alignment of the text perpendicular to the line o rotation: The 0/90/180/270 degree rotation of the text o color: The #[aa]rrggbb hex value of the text 52 3. Image • filename: The filename of an image • targetRect: The rectangle in which the image is displayed. The image will be automatically resized to fit into the target area. • sourceRect: The source rectangle to clip from a source image • compositionMode: Enter either source or source_over. The latter alpha blends with underlying objects. The former replaces the underlying values completely. 4. QR Codes Note: QR (quick response) codes appear as squares of black dots on a white background. They are used to encode URLs, email addresses, etc, and they can be scanned using readily available software for smart phones. Although the codes usually appear as black on white, you can, in theory, use any two contrasting colors. • targetRect: The rectangle in which the QR code is displayed o Regardless of the aspect ratio of this rectangle, the QR code itself will always be squared with the background color that fills the gaps. • QrCode (simple form): Contains the string to encode into the QR code. • QrCode (complex form): Contains an array of parameters for the QR code. The parameters can be any of the following: o color: The foreground color in the QR code (the default is black) o backgroundColor: The background color in the QR code (the default is white) o rotation: 0/90/180/270 degree rotation of the code. The code will scan regardless of rotation. o qrText: Contains the text to encode into the QR code. 53 Example: This code contains most of the roCanvasWidget features outlined above: rect=CreateObject("roRectangle", 0, 0, 1920, 1080) cw=CreateObject("roCanvasWidget", rect) aa=CreateObject("roAssociativeArray") aa["text"] = "Primal Scream" aa["targetRect"] = { x: 280, y: 180, w: 500, h: 30 } aa["textAttrs"] = { Color:"#AAAAAA", font:"Medium", HAlign:"Left", VAlign:"Top"} aa1=CreateObject("roAssociativeArray") aa1["text"] = "Movin' on up, followed by something else, followed by something else, followed by something else, followed by something else" aa1["targetRect"] = { x: 282, y: 215, w: 80, h: 500 } aa1["textAttrs"] = { Color:"#ffffff", font:"Large", fontfile:"usb1:/GiddyupStd.otf", HAlign:"Left", VAlign:"Top", rotation:"90"} array=CreateObject("roArray", 10, false) array.Push({ color: "5c5d5f" }) array.Push({ filename: "transparent-balls.png" }) array.Push(aa) aa2=CreateObject("roAssociativeArray") aa2["filename"] = "transparent-balls.png" aa2["CompositionMode"] = "source_over" aa2["targetRect"] = { x: 400, y: 200, w: 200, h: 200 } aa3=CreateObject("roAssociativeArray") 54 aa3["QrCode"] = "www.brightsign.biz" aa3["targetRect"] = { x: 100, y: 100, w: 400, h: 400 } aa4=CreateObject("roAssociativeArray") aa4["QrCode"] = { qrText:"www.brightsign.biz", rotation:"90" } aa4["targetRect"] = { x: 1200, y: 100, w: 400, h: 600 } aa5=CreateObject("roAssociativeArray") aa5["QrCode"] = { color:"#964969", backgroundColor:"#FFFF77", qrText:"www.brightsign.biz", rotation:"180" } aa5["targetRect"] = { x: 100, y: 600, w: 400, h: 400 } cw.Show() cw.EnableAutoRedraw(0) cw.SetLayer(array, 0) cw.SetLayer(aa1, 1) cw.SetLayer(aa1, 2) cw.SetLayer(aa3, 3) cw.SetLayer(aa4, 4) cw.SetLayer(aa5, 5) cw.EnableAutoRedraw(1) cw.ClearLayer(0) 55 roClockWidget This object places a clock on the screen. It has no extra interface, only construction arguments. Interfaces: ifTextWidget, ifWidget Object creation: CreateObject("roClockWidget", rect As roRectangle, res As roResourceManager, display_type As Integer) • • Rect: The rectangle in which the clock is displayed. The widget picks a font based on the size of the rectangle. display_type: Use 0 for date only, and 1 for clock only. To show both on the screen, you need to create two widgets. Example: rect=CreateObject("roRectangle", 0, 0, 300, 60) res=CreateObject("roResourceManager", "resources.txt") c=CreateObject("roClockWidget", rect, res, 1) c.Show() The resource manager is passed into the widget, which uses the following resources within "resources.txt" to display the time and date correctly. Here are the "eng" entries: [CLOCK_DATE_FORMAT] eng "%A, %B %e, %Y" [CLOCK_TIME_FORMAT] eng "%l:%M" [CLOCK_TIME_AM] 56 eng "AM" [CLOCK_TIME_PM] eng "PM" [CLOCK_DATE_SHORT_MONTH] eng "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec" [CLOCK_DATE_LONG_MONTH] eng "January|February|March|April|May|June|July|August|September|October|November|December" [CLOCK_DATE_SHORT_DAY] eng "Sun|Mon|Tue|Wed|Thu|Fri|Sat" [CLOCK_DATE_LONG_DAY] eng "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday" The following are the control characters for the date/time format strings: // // // // // // // // // // // // Date format %a %A %b %B %d %e %m %n %y %Y Abbreviated weekday name Long weekday name Abbreviated month name Full month name Day of the month as decimal 01 to 31 Like %d, the day of the month as a decimal number, but without leading zero Month name as a decimal 01 to 12 Like %m, the month as a decimal number, but without leading zero Two digit year Four digit year 57 // // // // // // // // Time format %H %I %k %l %M %S The hour using The hour using The hour using The hour using Minutes (00 to Seconds (00 to 24-hour 12-hour 24-hour 12-hour 59) 59) clock clock clock clock (00 to 23) (01 to 12) (0 to 23); single digits are preceded by a blank. (1 to 12); single digits are preceded by a blank. See the entry for roTextWidget for a description of ifTextWidget. The ifWidget interface provides the following: • • • • SetForegroundColor(color As Integer) As Boolean: Sets the foreground color in ARGB format. SetBackgroundColor(color As Integer) As Boolean: Sets the background color in ARGB format. SetFont(font_filename As String) As Boolean: Sets the font_filename using a TrueType font (for example, SD:/Ariel.ttf). SetBackgroundBitmap(background_bitmap_filename As String, stretch As Boolean) As Boolean: Sets the background bitmap. If stretch is True, then the image is stretched to the size of the window. • SetSafeTextRegion(region As roRectangle) As Boolean: Specifies the rectangle within the widget where the text can be drawn safely. • • • Show() As Boolean: Displays the widget. After creation, the widget is hidden until Show() is called. Hide() As Boolean: Hides the widget. GetFailureReason() As String: Yields additional useful information if a function return indicates an error. 58 roHtmlWidget This object embeds the WebKit HTML renderer. You can use multiple instances of roHtmlWidget at the same time. Object creation: Like other widgets, an roHtmlWidget is created with an roRectangle, which specifies the size and position that the widget occupies on the screen. Interfaces: ifHtmlWidget, ifMessagePort The ifHtmlWidget interface provides the following: • • • • GetFailureReason() As String: : Gives more information when a member function returns False. Hide() As Boolean: Hides the widget. Show() As Boolean: Shows the widget. SetURL(URL As String) As Boolean: Displays content from the specified URL. Note: When using SetUrl to retrieve content from local storage, you do not need to specify the full file path: SetUrl("file:/example.html"). If the content is located somewhere other than the current storage device, you can specify it within the string itself. For example, you can use the following syntax to retrieve content from a storage device inserted into the USB port when the current device is an SD card: SetUrl("file:///USB1:/example.html"). • MapFilesFromAssetPool(asset_pool As roAssetPool, asset_collection As roAssetCollection, pool_prefix As String, uri_prefix As String) As Boolean: Sets the mapping between the URL space and the pool files. • SetZoomLevel(scale_factor as Float): Adjusts the scale factor for the displayed page (the default equals 1.0). • EnableSecurity(a As Boolean) As Boolean: Enables security checks by the Webkit. Setting this method to False disables security checks. 59 • EnableMouseEvents() As Boolean: Enables response to button presses if True. Setting this method to False (the default) disables this feature. • SetPortriat(portrait_mode As Boolean) As Boolean: Sets the screen orientation to portrait if True. If this method is False (the default), the screen is oriented as a landscape. • SetAlpha(alpha As Integer) As Boolean: Sets the overall alpha level for the widget (the default equals 255). • EnableScrollbars(scrollbars As Boolean) As Boolean: Enables automatic scrollbars for content that does not fit into the viewport if True. Setting this method to False (the default) disables this feature. • AddFont(filename As String) As Boolean: Makes a font available for text rendering. The AddFont() method can be used to supply additional or custom typefaces for the WebKit renderer. These should be supplied in the form of TTF files, and the filename should be passed as the argument to AddFont(). • SetAppCacheDir(file_path As String) As Boolean: Sets the directory to use for storing the application cache (which services tags). The file path is passed to the method as a string (e.g. "SD:/appcache"). • SetAppCacheSize(maximum As Integer) As Boolean: Sets the maximum size (in bytes) for the application cache. Changing the storage size of the application cache will clear the cache and rebuild the cache storage. Depending on database-specific attributes, you will only be able to set the size in units that are equal to the page size of the database, which is established at creation. These storage units will occur only in the following increments: 512, 1024, 2048, 4096, 8192, 16384, 32768. • • EnableJavascript(a As Boolean) As Boolean SetUserAgent(user_agent As String) As Boolean: Changes the default user-agent string reported by WebKit. The following is an example of the default user-agent string, as sent by an XD1230: BrightSign/4.7.85.2-8-g1a6e6f6-td-debug (XD1230) Mozilla/5.0 (compatible; Linux mips) AppleWebKit/537.4 (KHTML, like Gecko) Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/537.4 60 The ifMessagePort interface provides the following: • SetPort (a As Object) An roMessagePort can be attached to an roHtmlWidget. It will then receive roHtmlWidgetEvent objects when something happens to the parent widget. An roAssociativeArray functions as the payload of the roHtmlWidgetEvent, and the payload can be retrieved using the GetData() method. Within the associative array, the reason key identifies the cause of the event. The reason key can return the following values: • • • load-started: The WebKit has started loading a page. load-finished: The WebKit has completed loading a page. load-error: The WebKit has failed to load a page. The uri key identifies the failing resource, and the message key provides some explanatory text. Filename Mapping HTML content that has been deployed via BrightAuthor will typically reside in the pool and have encrypted SHA1-based filenames. A mapping mechanism is required to allow any relative URIs contained in the HTML content to continue working and to locate the appropriate resources in their respective pool locations. An roHtmlWidget.MapFilesFromAssetPool() method can be used to bind part of the resource URI space onto pool locations, as long as it is used with the following: an roAssetPool object containing some assets, an roAssetCollection object identifying them, and two semi-arbitrary strings (URI_PREFIX and POOL_PREFIX). Any URI in the form "file:/[URI_PREFIX][RESOURCE_ID]" will be rewritten into the form "[POOL_PREFIX] [RESOURCE_ID]". It will then be located in the pool as if that name had been passed to the roAssetPoolFiles.GetPoolFilePath() method. This binding occurs for every instance of roHtmlWidget, so different mappings can be used for different bundles of content. 61 roImageBuffer Interfaces: ifImageBufferControl The ifImageBufferControl interface provides the following: • DisplayBuffer(a As Integer, b As Integer) As Boolean 62 roImagePlayer This object displays static bitmap images on the video display. The simplest way to use roImagePlayer is to make calls to DisplayFile() with the filename as a String. Alternatively, you can use PreloadFile() in conjunction with DisplayPreload() to have more control. Interfaces: ifImageControl The ifImageControl interface provides the following: • DisplayFile(image_filename As String) As Boolean: Displays the image with the specified filename. The image_filename string must point to a .png, .jpeg, or 8-bit, 24-bit, or 32-bit .bmp file. Note that .jpeg image files with CMYK color profiles are not supported. • DisplayFile(parameters As roAssociativeArray) As Boolean: Displays an image using an associative array of display parameters: o Filename o Mode: See the entry for SetDefaultMode() below for more details. o Transition: See the entry for SetDefaultTransition() below for more details. • PreloadFile(image_filename As String) As Boolean: Loads the specified image file into an offscreen memory buffer. • PreloadFile(parameters As roAssociativeArray) As Boolean: Loads an image file into an offscreen memrory buffer. Image display properties are determined by an associative array of parameters: o Filename • o Mode: See the entry for SetDefaultMode() below for more details. o Transition: See the entry for SetDefaultTransition() below for more details. DisplayPreload() As Boolean: Uses the on-screen memory buffer to display the image stored in the offscreen memory buffer using PreloadFile(). There are only two memory buffers: one is displayed on screen; and the other is used for preloading images. PreloadFile() can be called multiple times before 63 • • • • DisplayPreload() is called, and will keep loading into the same off-screen buffer. The DisplayFile() method calls PreloadFile() followed immediately by DisplayPreload(), so any previously preloaded image will be lost. If no image is preloaded, DisplayPreload() will have no effect. 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 SetDefaultMode(mode As Integer) As Boolean: Sets the default image display mode for DisplayFile() and PreloadFile(). If SetDefaultMode() is not called, then the default mode is set to 0 (equivalent to the image being centered without scaling). The supported display mode are listed below: o 0 - Center image: No scaling takes place. Cropping only occurs if the image is bigger than the screen. o 1 - Scale to fit: The image is scaled so that it is fully viewable, with its aspect ratio maintained. o 2 - Scale to fill and crop: The image is scaled so that it completely fills the screen, with its aspect ratio maintained. o 3 - Scale to fill: The image is stretched so that it fills the screen and the whole image is viewable. This means that the aspect ratio will not be maintained if it is different to that of the current screen resolution. • SetDefaultTransition(transition As Integer) As Boolean: Sets the transition to be used when the next image is displayed. The following are available transitions: o 0 - No transition, immediate blit. o 1 to 4 - Wipes from top, bottom, left and right. o 5 to 8 - Explodes from centre, top left, top right, bottom left, bottom right. o 10 to 11 - Venetian blinds vertical and horizontal. o 12 to 13 - Comb effect vertical and horizontal. o 14 - Fade out to background color, then back in. o 15 - Fade between current image and new image. o 16 to 19 - Slides from top, bottom, left and right. 64 o 20 to 23 – Slides entire screen from top, bottom, left, and right. o 24, 25 – Scales old image in, then the new one out again (this works as a pseudo "rotation" around a vertical and horizontal axis, respectively). o 26 to 29 – New image expands onto screen from right, left, bottom, and top, respectively. • • • • • SetRectangle(r As roRectangle) As Void OverlayImage(a As String, b As Integer, c As Integer) As Boolean GetRectangle() As Object CreateTestHole(hole As roRectangle) As Boolean SetTransitionDuration(duration As Integer) As Boolean: Sets the amount of time it takes (in milliseconds) for a specified transition effect to take place. The default transition duration is 1000 milliseconds. • • • DisplayBuffer(a As Object, b As Integer, c As Integer) As Boolean Hide() As Boolean: Hides the image currently being displayed by the roImagePlayer widget. Show() As Boolean: Shows the image currently being displayed by the roImagePlayer widget. X, Y: x and y indicate which position of the image to center as near as possible, or both x and y can be set to -1, which uses the center of the image as the point to position nearest to the center. To display images in a zone, SetRectangle() must be called. EnableZoneSupport() must be included in a script to use the zones functionality. Here are some example shell commands you can use to test the different display modes: Roku> Roku> Roku> Roku> image image image image filename.bmp filename.bmp filename.bmp filename.bmp 0 1 2 3 Roku> image filename.bmp 0 0 0 65 Roku> image filename.bmp 2 0 0 The following example script uses preloaded images to improve the UI speed when the user hits a key on the keyboard. As soon as a key is struck, the display switches to the new image, which has already been preloaded. The only possible delay occurs if the key is hit while the image is preloading. In this case, the image will display as soon as it is loaded. i = CreateObject("roImagePlayer") p = CreateObject("roMessagePort") k = CreateObject("roKeyboard") k.SetPort(p) i.PreloadFile("one.bmp") loop: i.DisplayPreload i.PreloadFile("two.bmp") Wait(0,p) i.DisplayPreload i.PreloadFile("one.bmp") Wait(0,p) goto loop 66 roImageWidget This object can be used in place of roImagePlayer in cases where the image is displayed within a rectangle. Using a roImageWidget can result in more pleasing aesthetics for image player creation. Beyond this, roImageWidget behaves identically to roImagePlayer. When displaying roImagePlayer within a rectangle, the following code is used: rectangle = CreateObject("roRectangle", 0, 0, 1024, 768) i = CreateObject("roImagePlayer") i.SetRectangle(rectangle) When utilizing an roImageWidget, the following code is used: rectangle = CreateObject("roRectangle", 0, 0, 1024, 768) i = CreateObject("roImageWidget", rectangle) Interfaces: ifImageControl See roImagePlayer for a description of ifImageControl and its attendant methods. We have added some overloaded PreloadFile and DisplayFile functions. These take an roAssociativeArray as a parameter. The roAssociativeArray stores various options to be passed. They must be used when displaying images across multiple screens in an array, or displaying a portion of an image though they can also be used in place of the original function calls. 67 Example: This code uses PreloadFile for a multiscreen display: i=CreateObject("roImageWidget") a=CreateObject("roAssociativeArray") a["Filename"] = "test.jpg" a["Mode"] = 1 a["Transition"] = 14 a["MultiscreenWidth"] = 3 a["MultiscreenHeight"] = 2 a["MultiscreenX"] = 0 a["MultiscreenY"] = 0 i.PreloadFile(a) i.DisplayPreload The filename, mode, and transition are the same values as documented above, but the multiscreen parameters are new. The MultiscreenWidth and MultiscreenHeight parameters specify the width and height of the multiple screen matrix. For example, 3x2 would be three screens wide and two screens high. The MultiscreenX and MultiscreenY specify the position of the current screen within that matrix. In the above case, on average only 1/6 of the image is drawn on each screen, though the image mode still applies so that, depending on the shape of the image, it may have black bars on the side screens. It is relatively simple, therefore, for an image widget to display part of an image based on its position in the multiscreen array. The following are default values for the parameters: Mode = 0 Transition = 0 MultiscreenWidth = 1 MultiscreenHeight = 1 MultiscreenX = 0 68 MultiscreenY = 0 Example: This code uses DisplayFile for displaying a portion of an image: i=CreateObject("roImageWidget") a=CreateObject("roAssociativeArray") a["Filename"] = "test.JPG" a["Mode"] = 0 a["SourceX"] = 600 a["SourceY"] = 600 a["SourceWidth"] = 400 a["SourceHeight"] = 400 i.DisplayFile(a) This displays just a portion of the image test JPG starting at coordinates SourceX, SourceY, and SourceWidth by SourceHeight in size. The viewmode is still honored as if it were displaying the whole file. 69 roRectangle This object is created with several parameters: CreateObject("roRectangle", x As Integer, y As Integer, width As Integer, height As Integer) Interfaces: ifRectangle The interface ifRectangle provides the following: • • • • • • • • SetX(x As Integer) As Void SetY(y As Integer) As Void SetWidth(width As Integer) As Void SetHeight(height As Integer) As Void GetX() As Integer GetY() As Integer GetWidth() As Integer GetHeight() As Integer SetRectangle calls honor the view mode/aspect ratio conversion mode set up by the user. If the user has set the videoplayer for letterboxing, it will occur if the video does not fit exactly into the new rectangle. 70 roShoutcastStream Object creation: roShoutcastStream takes a URL object, a maximum buffer size (in seconds), and an initial buffering duration (in seconds). CreateObject("roShoutcastStream", url_transfer, buffer size, buffer duration) Interfaces: ifShoutcastStream, ifSetMessagePort, ifSourceIdentity The ifShoutcastStream interface provides the following: • • • • • • • GetUrl() As String GetBufferedDuration() As Integer GetTimeSinceLastData() As Integer GetCurrentMetadata() As String Rebuffer() As Boolean AsyncSaveBuffer(a As String) As Boolean RestartBufferRecord() As Boolean The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifSourceIdentity interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity(a As Integer) 71 roShoutcastStreamEvent Interfaces: ifInt, ifSourceIdentity The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifSourceIdentity interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity(a As Integer) 72 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 object is created with several parameters: CreateObject("roTextField", xpos As Integer, ypos As Integer, width_in_chars As Integer, height_in_chars As Integer, metadata As Object) • • • • • xpos: The horizontal coordinate for the top left of the text field. ypos: The vertical coordinate for the top left of the text field. The top of the screen is equivalent to zero. width_in_chars: The width of the text field in character cells. height_in_chars: The height of the text field in character cells. metadata: An optional roAssociativeArray containing extra parameters for the text field. You can pass zero if you do not require this. Note: In TV modes a border around the screen may not be displayed due to overscanning. You may want to use the roVideoMode object functions GetSafeX and GetSafeY to ensure that the coordinates you use will be visible. The metadata object supports the following extra parameters: • • • • "CharWidth": The width of each character cell in pixels. "CharHeight": The height of each character cell in pixels. "BackgroundColor": The background color of the text field as an integer specifying eight bits (for each) for red, green and blue in the form &Hrrggbb. "TextColor": The color of the text as an integer specifying eight bits (for each) for red, green and blue in the form &Hrrggbb. 73 • "Size"= An alternative to "CharWidth" and "CharHeight" for specifying either normal size text (0) or double-sized text (1). Interfaces: ifTextField, ifStreamSend The ifTextField interface provides the following: • • • • Cls() As Void: Clears the text field. GetWidth() As Integer: Returns the width of the text field GetHeight() As Integer: Returns the height of the text field. SetCursorPos(x As Integer, y As Integer) As Void: Moves the cursor to the specified position. Subsequent output will appear at this position. • GetValue() As Integer: Returns the value of the character currently under the cursor. The ifStreamSend interface provides the following: • SendByte(byte As Integer) As Void: Writes the character indicated by the specified number at the current cursor position within the text field. It then advances the cursor. • SendLine(string As String) As Void: Writes the characters specified at the current cursor position followed by the end-of-line sequence. • SendBlock(string As Dynamic) As Void: Writes the characters specified at the current cursor position and advances the cursor to one position beyond the last character. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • SetSendEol(string As String) As Void: Sets the sequence sent at the end of a SendLine request. You should leave this at the default value of "chr(13)" for normal use. Note: The ifStreamSend interface is also described in the section documenting the various file objects. The interface is described again here in a manner more specific to the roTextField object. 74 As with any object that implements the ifStreamSend interface, a text field can be written to using the PRINT #textfield syntax. See the example below for more details. It is also possible to write to a text field using the syntax PRINT #textfield, @pos, where pos is the character position in the textfield. For example, if your textfield object has 8 columns and 3 rows, writing to position 17 writes to row 3, column 2 (positions 0-7 are in row 1; positions 8-15 are in row 2; and positions 16-23 are in the last row). When output reaches the bottom of the text field, it will automatically scroll. Example: meta = CreateObject("roAssociativeArray") meta.AddReplace("CharWidth", 20) meta.AddReplace("CharHeight", 32) meta.AddReplace("BackgroundColor", &H101010) ' Dark grey meta.AddReplace("TextColor", &Hffff00) ' Yellow vm = CreateObject("roVideoMode") tf = CreateObject("roTextField", vm.GetSafeX(), vm.GetSafeY(), 20, 20, meta) print #tf, "Hello World" tf.SetCursorPos(4, 10) print #tf, "World Hello" 75 roTextWidget This object is used to place text on the screen. Object creation: CreateObject("roTextWidget", r As roRectangle, line_count As Integer, text_mode As Integer, pause_time As Integer) • • • r : Create an roRectangle that contains the text. line_count: Determine the number of lines of text to show in the rectangle. text_mode: Use 0 for an animated view similar to teletype, 1 for static text, and 2 for simple text with no queue of strings. • pause_time: Determine how long each string is displayed prior to displaying the next string. CreateObject("roTextWidget", r As roRectangle, line_count As Integer, text_mode As Integer, array As roAssociativeArray) • • • r : Create an roRectangle that contains the text. line_count: Determine the number of lines of text to show in the rectangle. text_mode: Use 0 for an animated view similar to teletype, 1 for static text, and 2 for simple text with no queue of strings. • array: Create an associative array that can include the following values: o "LineCount": Determine the number of lines of text to show in the rectangle. o "TextMode": Use 0 for an animated view similar to teletype, or use 1 for static text. o "PauseTime": Determine how long each string is displayed prior to displaying the next string. This does not apply to mode 2 roTextWidget objects, in which the strings on screen are updated immediately. o "Rotation": Determine the rotation of the text in the widget: 0 degrees (0), 90 degrees (1), 180 degrees (2), or 270 degrees (3). 76 o "Alignment": Determine the alignment of the text: left (0), center (1), or right (2). Interfaces: ifTextWidget, ifWidget The ifTextWidget interface provides the following: • PushString(str As String) As Boolean: Adds the string to the list of strings to display in modes 0 and 1. Strings are displayed in order, and when the end is reached, the object loops, returning to the beginning of the list. In mode 2, the string is displayed immediately. • PopStrings(number_of_string_to_pop As Integer) As Boolean: Pops strings off the front of the list (using "last in, first out" ordering) in modes 0 and 1. This occurs the next time the widget wraps so that strings can be added to and removed from the widget seamlessly. In mode 2, the string is cleared from the widget immediately. • GetStringCount() As Integer: Returns the number of strings that will exist once any pending pops have taken place. • Clear() As Boolean: Clears the list of strings, leaving the widget blank and able to accept more PushString calls. This ifWidget interface provides the following: • • • • • • • SetForegroundColor(color As Integer) As Boolean: Sets the foreground color in ARGB format. SetBackgroundColor(color As Integer) As Boolean: Sets the background color in ARGB format. SetFont(font_filename As String) As Boolean: Sets the font_filename using a TrueType font (for example, SD:/Ariel.ttf). SetBackgroundBitmap(background_bitmap_filename As String, stretch As Boolean) As Boolean: Sets the background bitmap. If stretch is True, then the image is stretched to the size of the window. SetSafeTextRegion(region As roRectangle) As Boolean: Specifies the rectangle within the widget where the text can be drawn safely. Show() As Boolean: Displays the widget. After creation, the widget is hidden until Show() is called. Hide() As Boolean: Hides the widget. 77 • GetFailureReason() As String: Yields additional useful information if a function return indicates an error. The top 8 bits of the color value are "alpha," affecting both the foreground text color and the widget background color. Zero is equivalent to fully transparent and 255 to fully non-transparent. This feature allows effects similar to subtitles. For example, you can create a semi-transparent black box containing text over video. Modes 0 and 1 are useful for displaying RSS feeds and ticker-type text. However, for dynamic data where immediate screen updates are required, mode 2 is more appropriate. Mode 2 allows text to be drawn immediately to the screen. 78 roVideoEvent, 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: 1 Undefined: Player is in an undefined state. 2 Stopped: Playback of the current media item is stopped. 3 Playing: The current media item is playing. 4 ScanForward: The current media item is fast forwarding. 5 ScanReverse: The current media item is rewinding. 6 Buffering: The current media item is getting additional data from the server. 7 Waiting: Connection is established, but the server is not sending data. Waiting for session to begin. 8 MediaEnded: The media item has completed playback. 9 Transitioning: Player is preparing new media item. 10 Ready: Player is ready to begin playing. 11 Reconnecting: Player is reconnecting to the stream. 12 TimeHit: A particular timecode is hit. See roVideoPlayer. Interfaces: ifInt, ifData The ifInt interface contains the event ID enumerated above and provides the following: • • • • GetInt As Integer() SetInt(a As Integer) GetSourceIdentity() As Integer SetSourceIdentity() As Integer The ifData interface contains userdata and provides the following: • GetData() As Integer 79 • SetData(a As Integer) Example: vp_msg_loop: msg=Wait(tiut, p) if type(msg)="roVideoEvent" then if debug then print "Video Event";msg.GetInt() if msg.GetInt() = 8 then if debug then print "VideoFinished" retcode=5 return endif else if type(msg)="roGpioButton" then if debug then print "Button Press";msg if escm and msg=BM then retcode=1:return if esc1 and msg=B1 then retcode=2:return if esc2 and msg=B2 then retcode=3:return if esc3 and msg=B3 then retcode=4:return else if type(msg)="rotINT32" then if debug then print "TimeOut" retcode=6 return endif goto vp_msg_loop 80 roVideoInput This object allows playback of video supplied by a video capture dongle. roVideoInput is created with no parameters: CreateObject("roVideoInput ") Interfaces: ifVideoInput The ifVideoInput interface provides the following: • • GetStandards As roArray(String) GetInputs As roArray(String): These return an array of strings describing the various inputs and video standards that the video capture device supports. The following are the possible standards that can be returned: PAL-D/K, PAL-G, PAL-H, PAL-I, PAL-D, PAL-D1, PAL-K, PAL-M, PAL-N, PAL-Nc, PAL-60, SECAM-B/G, ECAM-B, SECAM-D, SECAM-G, SECAM-H, SECAM-K, SECAM-K1, SECAM-L, SECAM-LC, SECAM-D/K, NTSC-M, NTSCMj, NTSC-443, NTSC-Mk, PAL-B and PAL-B1. Inputs returned are s-video and composite. • • • • • SetStandard(As String) As Boolean GetCurrentStandard() As String SetInput(As String) As Boolean GetCurrentInput() As String: Use the above to get and set the input and video standard. GetControls As roArray(String): Returns the possible controls on the input. These include "Brightness," "Contrast," "Saturation," "Hue," and others. • SetControlValue(control_name As String, value As Integer) As Boolean: Sets the value of the specified control. 81 • GetCurrentControlValue(control_name As String) As roAssociativeArray: Returns an associative array with 3 members: "Value," "Minimum," and "Maximum." "Value" is the current value, and the possible range is specified by "Minimum" and "Maximum." • • • GetFormats() As Object SetFormat(a As String, b As Integer, c As Integer) As Boolean GetCurrentFormat() As String Example: This script creates a full-screen display with the video capture dongle as the video source. v=CreateObject("roVideoPlayer") i=CreateObject("roVideoInput") p=CreateObject("roMessagePort") vm=CreateObject("roVideoMode") vm.SetMode("1280x720x60p") r = CreateObject("roRectangle", 0, 0, 1280, 720) v.SetRectangle(r) i.SetInput("s-video") i.SetStandard("ntsc-m") v.PlayEx(i) 82 roVideoMode This object allows you to configure resolution and other video output settings. The same video resolution is applied to all video outputs on a BrightSign player. Video or images that are subsequently decoded and displayed will be scaled (using the hardware scalar) to this output resolution if necessary. You can also use roVideoMode.GetHdmiInputStatus() to retrieve information about the HDMI input on the XD1230. The roVideoMode object sends an roHdmiInputChanged object whenever the hotplug status of the HDMI input changes. Interfaces: ifVideomode, ifSetMessagePort The ifVideoMode interface provides the following: • SetMode(mode As String) As Boolean: Sets the video output mode. The supported video modes are listed at the end of this entry. If the specified video mode is different from the object’s current video mode, the unit will reboot and change the video mode to the new setting during system initialization. Note: BrightSign hardware has a video anti-aliasing low-pass filter that is set automatically. • Set3dMode(mode As Integer) As Boolean: Sets the 3D video output mode, which is specified by passing one the following parameters: o 0: Standard mono video (default) o 1: Side-by-side stereo video o 2: Top-and-bottom stereo video • Screenshot(parameters As roAssociativeArray) As Boolean: Captures a screenshot of the video and graphics layer as a .jpeg or .bmp file in the temp:/ directory. The screenshot process is configured by passing an associative array of parameters to the method: o filename: The name of the image file that will be saved. o Width: The width dimension of the image file. o Height: The height dimension of the image file. 83 Note: The default dimensions of the image file is 640x480. o filetype: A string determining whether the image is a "JPEG" or "BMP" file type. o quality: An integer value (between 0 and 100) that determines the image quality of the screenshot. This o parameter is set to 50 by default. Async: An integer value that determines whether the screenshot should be taken synchronously or asynchronously. If set to 0, the function returns True after the image file has successfully finished writing. If set to 1, the function will return True prior to saving the file, then return an roScreenShotComplete event once the file has finished writing. • • • • • • • GetResX() As Integer: Returns the current width of the graphics plane. GetResY() As Integer: Returns the current height of the graphics plane. GetVideoResX() As Integer: Returns the current width of the video plane. GetVideoResY() As Integer: Returns the current height of the video plane. GetOutputResX() As Integer: Returns the width of the display for the current video mode. GetOutputResY() As Integer: Returns the height of the display for the current video mode. GetSafeX() As Integer: Returns the horizontal coordinate for the upper-left corner of the "safe area". For modes that are generally displayed with no overscan, this will be zero. • GetSafeY() As Integer: Returns the vertical coordinate for the upper-left corner of the "safe area". For modes that are generally displayed with no overscan, this will be zero. • GetSafeWidth() As Integer: Returns the width of the "safe area." For modes that are generally displayed with no overscan, this will return the same as GetResX. • GetSafeHeight() As Integer: Returns the height of the "safe area." For modes that are generally displayed with no overscan, this will return the same as GetResY. Note: More information about safe areas can be found here: o http://en.wikipedia.org/wiki/Safe_area o http://en.wikipedia.org/wiki/Overscan_amounts • AdjustGraphicsColor(parameters As roAssociativeArray) As Boolean: Adjusts the video and graphics output of the player using the following parameters, which can be passed to the method as an associative 84 array: "brightness", "hue", "contrast", "saturation". Each parameter has a default value of 0 and can accept a range of values between -1000 and 1000. • GetHdmiInputStatus() As roAssociativeArray: Returns an associative array of roInt objects if an HDMI input is currently connected to the device (XD1230 only). This method will return Invalid if there is currently no HDMI input source. The array contains the following parameters: o width: Lists the pixel width of the video input. o height: Lists the pixel height of the video input. o interlaced: Returns 1 if the video input is interlaced, 0 if it is not interlaced. o device_present: Returns 1 if there is an HDMI input device present, 0 if there is no HDMI input device present. • SetBackgroundColor(a As Integer) As Boolean: Specifies the background color using an #rrggbb hex value. • SetPowerSaveMode(power_save_enable As Boolean) As Boolean: Turns off the syncs for VGA output and the DAC output for component video. This will cause some monitors to go into standby mode. • EnableVideo(enable As Boolean) As Boolean: Enables video output from the device if True. Setting this method to False disables all video output from the device. This method is set to True by default. • IsAttached(connector As String) As Boolean: Returns True if the specified video connector is attached to an output device. This method can be passed the following parameters (note that they are case sensitive): o "hdmi" o "vga" • • • GetBestMode(connector As String) As String GetMode() As String: Returns the current video mode of the device, which is specified using the SetMode() method. SetModeForNextBoot(video_mode As String)As Boolean: Specifies the target video mode of the device the next time it reboots. Once a video mode is specified using SetMode(), it can only be changed by a device reboot. 85 • • • GetModeForNextBoot() As String: Returns the target video mode of the device the next time it reboots. The return value is specified with the SetModeForNextBoot() method. HdmiAudioDisable(disable As Boolean) As Boolean: Disables audio output if True. This method is set to False by default. SetMultiscreenBezel(x_pct As Integer, y_pct As Integer) As Boolean: Adjusts the size of the bezel used in calculations when using multiscreen displays for video and images. It allows users to compensate for the width of their screen bezels in multiscreen configurations. The calculations for the percentages are as follows: x_percentage = (width_of_bezel_between_active_screens / width_of_active_screen) * 100 y_percentage = (height_of_bezel_between_active_screens / height_of_active_screen) * 100 The bezel measurement is therefore the total of the top and bottom bezels in the y case, or the left and right bezels in the x case. When this value is set correctly, images spread across multiple screens take account of the bezel widths, leading to better alignment of images. • SaveEdids(filename As String) As Boolean: Saves the EDID information of the display(s) connected via HDMI and/or VGA. The EDID fields are saved sequentially as raw binaries into the specified file. The EDID sets are two 2kb each, resulting in a maximum file size of 4kb. This method returns True upon success and False upon failure. • GetEdidIdentity(a As Boolean) As roAssociativeArray: Returns an associative array with EDID information from a compatible monitor/television connected over HDMI. These are the possible parameters: o serial_number_string o year_of_manufacture o monitor_name o manufacturer o text_string 86 o serial_number o product o week_of_manufacture The system will generate an roHdmiEdidChanged event when an HDMI cable is hotplugged and the EDID information changes. Calling GetEdidIdentity(1) at this point retrieves the new EDID information. The ifSetMessagePort interface provides the following: • SetPort(obj As Object) As Void Supported Video Modes The following are supported modes that can be passed to SetMode(): • • • "auto" "640x480x60p" "800x600x60p" (The HD210w and HD1010w support "800x600x75p" instead) • • • • • • • • • • • • "1024x768x60p" (The HD210w and HD1010w support "1024x768x75p" instead) "1280x768x60p" "1280x800x60p" "1360x768x60p" "720x576x50p" "720x480x60p" "1280x720x50p" "1280x720x59.94p" "1280x720x60p" "1920x1080x50i" "1920x1080x59.94i" "1920x1080x60i" 87 • • • "1920x1080x29.97p" "1920x1080x50p" "1920x1080x60p" If the mode is set to "auto," the BrightSign will try to determine the best video mode to use based on connected hardware. The algorithm is as follows: 1. Try VGA first – If VGA is attached, use the best mode as reported by the monitor that BrightSign supports. 2. Try HDMI next – If HDMI is attached, use the best mode as reported by the monitor that BrightSign supports. 3. Default to 1024x768x75p. 88 roVideoPlayer A Video Player is used to play back video files (using the generic ifMediaTransport interface). If the message port is set, the object will send events of type roVideoEvent. All object calls are asynchronous. That is, video playback is handled in a different thread from the script. The script will continue to run while video is playing. Decoded video will be scaled to the output resolution specified by roVideoMode. Interfaces: ifIdentity, ifSetMessagePort, ifAudioControl, ifAudioAuxControl, ifVideoControl, ifMediaTransport. The ifIdentity interface provides the following: • GetIdentity() As Integer The ifSetMessagePort interface provides the following: • SetPort(roMessagePort As Object) As Void See roAudioPlayer for an explanation of ifAudioControl. The ifAudioAuxControl interface provides the following: • • • • • • • MapStereoOutputAux(mapping As Integer) As Boolean SetVolumeAux(a As Integer) As Boolean SetChannelVolumesAux(channel_mask As Integer, b As Integer) As Boolean SetAudioOutputAux(audio_output As Integer) As Boolean SetAudioModeAux(audio_mode As Integer) As Boolean SetAudioStreamAux(stream_index As Integer) As Boolean SetUsbAudioPortAux(a As Integer) As Boolean The ifVideoControl interface provides the following: 89 • • • • • PlayStaticImage(filename As String) As Boolean SetViewMode(mode As Integer) As Boolean SetRectangle(r As roRectangle) As Void EnableSafeRegionTrimming(a As Boolean) As Boolean AdjustVideoColor(parameters As roAssociativeArray) As Boolean: Adjusts the video and graphics output of the player using the following parameters, which can be passed to the method as an associative array: "brightness", "hue", "contrast", "saturation". Each parameter has a default value of 0 and can accept a range of values between -1000 and 1000. The ifMediaTransport interface provides the following: • • • • • • • • • • • • PlayFile(filename As String) As Boolean PlayFile(parameters As roAssociativeArray) As Boolean PreloadFile(parameters As roAssociativeArray) As Boolean Stop() As Boolean Play() As Boolean SetLoopMode(mode As Integer) As Boolean ClearEvents() As Boolean AddEvent(userdata As Integer, time_in_ms As Integer) As Boolean StopClear() As Boolean Pause() As Boolean Resume() As Boolean PlayEx(a As Object) As Boolean If you wish to use a view mode different from the default, you must set it prior to starting video playback. view_mode values: 90 0 – Scale to fill (default). The aspect ratio can change. 1 – Letterboxed and centered. The aspect ratio is maintained, and the video has black borders. 2 – Full screen and centered. The aspect ratio is maintained and the screen is filled. To display the video in a zone, SetRectangle must be called. EnableZoneSupport must be called to use the zones functionality. MPEG2 video files are encoded with a specific aspect ratio, and output display resolutions have an aspect ratio. Video display modes 1 and 2 use these aspect ratios to ensure that the video-file aspect ratio is preserved when it is displayed. This will fail only when a widescreen monitor displays a 4:3 output resolution such as 800x600 across the whole screen (i.e. the monitor does not respect the aspect ratio). Please note that this feature relies on the correct aspect ratio marking of the MPEG2 video files. Unfortunately, not all files are marked correctly. Users can add events that 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. Example: This script uses timecode events. The script prints out 2, 5, and 10 into the video at 2 seconds, 5 seconds, and 10 seconds. The msg is approaching frame accurate. 10 20 30 40 50 60 70 80 v = CreateObject("roVideoPlayer") p = CreateObject("roMessagePort") v.SetPort(p) ok = v.AddEvent(2, 2000) ' Add timed events to video ok = v.AddEvent(5, 5000) ok = v.AddEvent(10, 10000) ok = v.AddEvent(100, 100000) ok = v.PlayFile("SD:/C5_d5_phil.vob") 90 msg = Wait(0,p) ' Wait for all events 91 95 if msg.GetInt() = 8 then stop ' End of file 100 if msg.GetInt() <> 12 goto 90 ' I only care about time events 110 print msg.GetData() ' Print out index when the time event happens 120 goto 90 Calling PlayStaticImage displays an image on the video layer. The image is stretched to fill the video rectangle. Multiscreen video playback We have also added some overloaded PreloadFile and PlayFile functions. These take a roAssociativeArray as a parameter, which stores all the various options to be passed in. They must be used when displaying images across multiple screens in an array, or displaying windowed portions of a video, though they can also be used in place of the original function calls. Example: This script uses the PreloadFile for a multiscreen display: v=CreateObject("roVideoPlayer") a=CreateObject("roAssociativeArray") a["Filename"] = "test.ts" a["MultiscreenWidth"] = 3 a["MultiscreenHeight"] = 2 a["MultiscreenX"] = 0 a["MultiscreenY"] = 0 v.PreloadFile(a) … … v.Play() 92 The filename is the same as documented earlier, but the multiscreen parameters are new. MultiscreenWidth and MultiscreenHeight specify the width and height of the multiple-screen matrix. For example, 3x2 would be 3 screens wide and 2 high. MultiscreenX and MultiscreenY specify the position of the current screen within that matrix. In the case above, on average only 1/6th of the video is drawn on each screen (though the view mode still applies), so depending on the shape of the video, it may have black bars on the side screens. In this way, it is relatively simple for a video player to display part of an image based on its position in the multiscreen array. PreloadFile does all of the preliminary work to get ready to play the specified video clip, including stopping the playback of the previous video file. The call to "Play" starts the playback. This is good for synchronizing video across multiple players as they can all be prepared ready to play and then will immediately start playing when the "Play" command is issued. This reduces synchronization latencies. The following are the default values for the parameters: MultiscreenWidth = 1 MultiscreenHeight = 1 MultiscreenX = 0 MultiscreenY = 0 Example: Here is a script using PlayFile for displaying a portion of a video: v=CreateObject("roVideoPlayer") a=CreateObject("roAssociativeArray") a["Filename"] = "test.ts" a["SourceX"] = 100 a["SourceY"] = 100 a["SourceWidth"] = 1000 93 a["SourceHeight"] = 500 v.PlayFile(a) This displays a windowed portion of the video test.ts starting at coordinates SourceX, SourceY, and SourceWidth by SourceHeight in size. The viewmode is still honored as if displaying the whole file. RF Channel Scanning The PlayFile() method can be used for channel scanning and handling functionality similar to roChannelManager. To use PlayFile() for channel scanning, pass an roAssociativeArray with the following possible parameters: • • • • • VirtualChannel RfChannel SpectralInversion o INVERSION_ON o INVERSION_OFF o INVERSION_AUTO ModulationType o QAM_64 o QAM_256 o QAM_AUTO o 8VSB VideoCodec o MPEG1-Video o MPEG2-Video o MPEG4Part2-Video o H264 o H264-SVC 94 • • • • o H264-MVC o AVSC AudioCodec o MPEG-Audio o AAC o AAC+ o AC3 o AC3+ o DTS VideoPid AudioPid PcrPid The VirtualChannel and RfChannel parameters must be present for PlayFile() to scan correctly. If you specify only these parameters, the player will scan the RF channel for a QAM/ATSC signal and attempt to retrieve the specified virtual channel from the results. The results from this action are cached so that subsequent calls to PlayFile() will take much less time. Providing the SpectralInversion and/or ModulationType parameters will further speed up the scanning process. If all parameters are supplied, then no scanning is required and the player can tune to the channel immediately. If one or more of the optional parameters is missing, then the player must parse the transport stream metadata to find the appropriate values for the supplied VirtualChannel and RfChannel. 95 roTouchCalibrationEvent Interfaces: ifInt, ifIntOps The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifIntOps interface provides the following: • ToStr() As String 96 roTouchEvent Interfaces: ifInt, ifPoint, ifEvent The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifPoint interface provides the following: • • • • GetX() GetY() SetX(a SetY(a As As As As Integer Integer Integer) Integer) The ifEvent interface provides the following: • • GetEvent() As Integer SetEvent(a As Integer) 97 roTouchScreen This object allows you to accept events from touchscreen panels or mice. Not all touchscreens are supported. However, we are always working on more driver support. Please see this FAQ for a full list of supported touchscreens, or contact sales@brightsign.biz if you want to know whether a specific touch-screen model supported. An roTouchScreen instance responds to the clicks of a USB mouse in the same way it responds to touch events on a touchscreen. To use a touchscreen, follow these general steps: 1. Create an roTouchScreen object. 2. Use SetPort() to specify which roMessagePort should receive touch events. 3. Define one or more touch regions. a. A touch region may be rectangular or circular. b. When someone touches the screen anywhere inside the area of a touch region, an event will be sent to the message port. 4. Process the events. Note: If touch areas overlap such that a touch hits multiple regions, an event for each affected region will be sent. The roTouchScreen object supports rollover regions. Rollovers are based around touch regions. When a rectangular or circular region is added, it defaults to having no rollover. You can enable a rollover using the touch region’s ID and specifying an on and off image. Whenever the mouse cursor is within that region, the on image is displayed. In all other cases, the off image is displayed. This allows buttons to be highlighted as the mouse cursor moves over them. Interfaces: ifTouchScreen, ifSetMessagePort, ifTouchScreenCalibration, ifSerialControl 98 The ifTouchScreen interface provides the following: • • • • • • • SetResolution(x As Integer, y As Integer) As Void AddRectangleRegion(x As Integer, y As Integer, w As Integer, h As Integer, userid As Integer) As Void AddCircleRegion(x As Integer, y As Integer, radius As Integer, userid As Integer) As Void ClearRegions(): Clears the list of regions added using AddRectangleRegion() or AddCircleRegion() so that any contacts in those regions no longer generate events. This call has no effect on the rollover graphics. GetDeviceName() As String SetCursorPosition(x As Integer, y As Integer) As Void SetCursorBitmap(filename As String, x As Integer, y As Integer) As Void: Specifies a BMP or PNG file as the mouse cursor icon. This method also accepts a "hot spot" (i.e. the point within the icon rectangle that will trigger events when the mouse is clicked) as a set of x,y coordinates. The icon can be a rectangle of any width or height. The colors are specified internally in YUV (6-4-4 bits respectively), but pixels in the passed image file can be one of 16 different colors. These colors are 16 bits, with 14 bits of color and 2 bits of alpha. If you use all of the alpha levels on all shades, then you limit the number of available shades to five (five shades at three alpha levels plus one fully transparent color gives 16). • • EnableCursor(enable As Boolean) As Void EnableRollover(region_id As Integer, on_image As String, off_image As String, cache_image As Boolean, image_player As Object) As Void: Enables a rollover for a touch region. The function accepts the ID of the touch region, as well as two strings specifying the names of the on and off bitmap images, a cache setting, and the image player that draws the rollover. The cache_image parameter simply tells the script whether to keep the bitmaps loaded in memory or not. This setting uses up memory very quickly, so we recommend that cache_image normally be set to 0. • EnableRegion(region_id As Integer, enabled As Boolean) As Void: Enables or disables a rollover region. The function accepts the ID of the touch region, as well as a Boolean value (True or False). The rollover 99 regions default to "enabled" when created, but you can set up all of the regions at the start of your script and then enable the current ones when required. • • SetRollOverOrigin(region_id As Integer, x As Integer, y As Integer) As Void: Changes the origin so that more (or less) of the screen changes when the mouse rolls in and out of the region. This means that bitmaps that are larger than the region can be drawn. The default requirement is that rollover bitmaps be the same size and position as the touch region. Note that the bitmap is square for circular regions. The default origin for circular regions is x - r, y – r, where x, y is the center and r is the radius. IsMousePresent() As Boolean: Returns whether a relative pointing device is attached or not. Note: This does not work for absolute devices like touchscreens. • EnableSerialTouchscreen(a As Integer) As Boolean • SetSerialTouchscreenConfiguration(a As String) As Boolean • GetDiagnosticInfo() As String: Returns an HTML string with captured information describing hardware that was connected and events that occurred during the calibration process. This method is used by the calibration script to diagnose touchscreen issues. The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifTouchScreenCalibration interface provides the following: • • StartCalibration() As Boolean GetCalibrationStatus() As Integer The ifSerialControl interface provides the following: • SetBaudRate(baud_rate As Integer) As Boolean: Sets the baud rate of the device. The supported baud rates are as follows: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400. • NotUsed1(a As String) 100 • • SetMode(a As String) As Boolean NotUsed2(a As Boolean) As Boolean The roTouchScreen interface sends events of type roTouchEvent, which provides the following: • • • ifInt: The userid of the touched region. ifPoint: The x,y coordinates of the touch point. This interface is not normally needed. ifPoint has two member functions: GetX As Integer and GetY As Integer. ifEvent: The mouse events. ifEvent has one member function: GetEvent() As Integer. Example: This code loops a video and waits for a mouse click or touchscreen input. It outputs the coordinates of the click or touch to the shell if it is located within the defined region. 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 if type(msg)="roTouchEvent" then 101 print "x,y=";msg.GetX();msg.GetY() endif goto loop: Example: This code includes 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" point t.SetCursorBitmap("cursor.bmp", 16, 16) t.SetResolution(1024, 768) t.SetCursorPosition(512, 389) REM REM Pass enable cursor display: TRUE for on, and FALSE for off REM The cursor will only enable if there is a mouse attached REM t.EnableCursor(TRUE) Example: This code includes a rollover region and mouse support. img=CreateObject("roImagePlayer") t=CreateObject("roTouchScreen") p=CreateObject("roMessagePort") t.SetPort(p) 102 t.SetCursorBitmap("cursor.bmp", 16, 16) t.SetResolution(1024, 768) t.SetCursorPosition(512, 389) t.EnableCursor(1) img.DisplayFile("\menu.bmp") REM Adds a rectangular touch region REM Enables rollover support for that region REM Sets the rollover origin to the same position as the touch region REM t.AddRectangleRegion(0, 0, 100, 100, 1) t.EnableRollOver(1, "on.bmp", "off.bmp", true, img) t.SetRollOverOrigin(1, 0, 0) 103 FILE OBJECTS roAppendFile This object can be used to create a new file or append information to the end of an existing file. CreateObject("roAppendFile", filename As String): Creating an roAppendFile object opens an existing file or creates a new file. The current position is set to the end of the file, and all writes are made to the end of the file. Interfaces: ifStreamRead, ifStreamSend, ifStreamSeek The ifStreamRead interface provides the following: • SetReceiveEol(eol_sequence As String) As Void: Sets the EOL sequence when reading from the stream. • ReadByte() As Integer: Reads a single byte from the stream, blocking if necessary. If the EOF is reached or there is an error condition, then a value less than 0 is returned. • ReadByteIfAvailable() As Integer: Reads a single byte from the stream if one is available. If no bytes are available, it returns immediately. A return value less than 0 indicates either that the EOF has been reached or no byte is available. • ReadLine() As String: Reads until it finds a complete end of the line sequence. If it fails to find the sequence within 4096 bytes, then it returns the 4096 bytes that are found. No data is discarded in this case. • ReadBlock(size As Integer) As String: Reads the specified number of bytes. The number is limited to 65536 bytes. In the event of an EOF or an error, fewer bytes than requested will be returned. Any null bytes in the file will mask any further bytes. 104 • AtEof() As Boolean: Returns True if an attempt has been made to read beyond the end of the file. If the current position is at the end of the file, but no attempt has been made to read beyond it, this method will return False. The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • • Flush() AsyncFlush() The ifStreamSeek interface provides the following: • SeekAbsolute(offset As Integer) As Void: Seeks 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. • SeekRelative(offset As Integer) As Void: Seeks to the specified offset relative to the current position. If the ultimate offset is beyond the end of the file, then the file will be extended as described in SeekAbsolute(). • • SeekToEnd() As Void: Seeks to the end of the file. CurrentPosition() As Integer: Retrieves the current position within the file. 105 roCreateFile This object can be used to write a new file or overwrite an existing file. CreateObject("roCreateFile", filename As String): Creating an roCreateFile object opens an existing file or creates a new file. If the file exists, it is truncated to a size of zero. Interfaces: ifReadStream, ifStreamSend, ifStreamSeek The ifReadStream interface provides the following: • SetReceiveEol(eol_sequence As String) As Void: Sets the EOL sequence when reading from the stream. • ReadByte() As Integer: Reads a single byte from the stream, blocking if necessary. If the EOF is reached or there is an error condition, then a value less than 0 is returned. • ReadByteIfAvailable() As Integer: Reads a single byte from the stream if one is available. If no bytes are available, it returns immediately. A return value less than 0 indicates either that the EOF has been reached or no byte is available. • ReadLine() As String: Reads until it finds a complete end of the line sequence. If it fails to find the sequence within 4096 bytes, then it returns the 4096 bytes that are found. No data is discarded in this case. • ReadBlock(size As Integer) As String: Reads the specified number of bytes. The number is limited to 65536 bytes. In the event of an EOF or an error, fewer bytes than requested will be returned. Any null bytes in the file will mask any further bytes. • AtEof() As Boolean: Returns True if an attempt has been made to read beyond the end of the file. If the current position is at the end of the file, but no attempt has been made to read beyond it, this method will return False. The ifStreamSend interface provides the following: 106 • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • • Flush() AsyncFlush() The ifStreamSeek interface provides the following: • SeekAbsolute(offset As Integer) As Void: Seeks 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. • SeekRelative(offset As Integer) As Void: Seeks to the specified offset relative to the current position. If the ultimate offset is beyond the end of the file, then the file will be extended as described in SeekAbsolute(). • • SeekToEnd() As Void: Seeks to the end of the file. CurrentPosition() As Integer: Retrieves the current position within the file. 107 roReadFile This object opens and reads a specified file. Object creation: CreateObject("roReadFile", filename As String): Creating an roReadFile object opens the specified file for reading only. Object creation fails if the file does not exist. Interfaces: ifStreamRead, ifStreamSend, ifStreamSeek The ifStreamRead interface provides the following: • SetReceiveEol(eol_sequence As String) As Void: Sets the EOL sequence when reading from the stream. • ReadByte() As Integer: Reads a single byte from the stream, blocking if necessary. If the EOF is reached or there is an error condition, then a value less than 0 is returned. • ReadByteIfAvailable() As Integer: Reads a single byte from the stream if one is available. If no bytes are available, it returns immediately. A return value less than 0 indicates either that the EOF has been reached or no byte is available. • ReadLine() As String: Reads until it finds a complete end of the line sequence. If it fails to find the sequence within 4096 bytes, then it returns the 4096 bytes that are found. No data is discarded in this case. • ReadBlock(size As Integer) As String: Reads the specified number of bytes. The number is limited to 65536 bytes. In the event of an EOF or an error, fewer bytes than requested will be returned. Any null bytes in the file will mask any further bytes. • AtEof() As Boolean: Returns True if an attempt has been made to read beyond the end of the file. If the current position is at the end of the file, but no attempt has been made to read beyond it, this method will return False. 108 The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • • Flush() AsyncFlush() The ifStreamSeek interface provides the following: • SeekAbsolute(offset As Integer) As Void: Seeks 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. • SeekRelative(offset As Integer) As Void: Seeks to the specified offset relative to the current position. If the ultimate offset is beyond the end of the file, then the file will be extended as described in SeekAbsolute. • • SeekToEnd() As Void: Seeks to the end of the file. CurrentPosition() As Integer: Retrieves the current position within the file. 109 roReadWriteFile The object opens a file and allows both reading and writing operations on that file. CreateObject("roReadWriteFile", filename As String): Creating an roReadWriteFile object opens an existing file for both reading and writing. Object creation fails if the file does not exist. The current position is set to the beginning of the file. Interfaces: ifReadStream, ifStreamSend, ifStreamSeek The ifReadStream interface provides the following: • SetReceiveEol(eol_sequence As String) As Void: Sets the EOL sequence when reading from the stream. • ReadByte() As Integer: Reads a single byte from the stream, blocking if necessary. If the EOF is reached or there is an error condition, then a value less than 0 is returned. • ReadByteIfAvailable() As Integer: Reads a single byte from the stream if one is available. If no bytes are available, it returns immediately. A return value less than 0 indicates either that the EOF has been reached or no byte is available. • ReadLine() As String: Reads until it finds a complete end of the line sequence. If it fails to find the sequence within 4096 bytes, then it returns the 4096 bytes that are found. No data is discarded in this case. • ReadBlock(size As Integer) As String: Reads the specified number of bytes. The number is limited to 65536 bytes. In the event of an EOF or an error, fewer bytes than requested will be returned. Any null bytes in the file will mask any further bytes. • AtEof() As Boolean: Returns True if an attempt has been made to read beyond the end of the file. If the current position is at the end of the file, but no attempt has been made to read beyond it, this method will return False. 110 The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • • Flush() AsyncFlush() The ifStreamSeek interface provides the following: • SeekAbsolute(offset As Integer) As Void: Seeks 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. • SeekRelative(offset As Integer) As Void: Seeks to the specified offset relative to the current position. If the ultimate offset is beyond the end of the file, then the file will be extended as described in SeekAbsolute(). • • SeekToEnd() As Void: Seeks to the end of the file. CurrentPosition() As Integer: Retrieves the current position within the file. 111 HASHING AND STORAGE OBJECTS roBrightPackage An roBrightPackage object represents a .zip file. The .zip file can include arbitrary content or can be installed on a storage device to provide content and script updates (for example, to distribute updates via USB thumb drives). Object creation: CreateObject("roBrightPackage", filename As String) • Filename: The filename for the .zip file. Interfaces: ifBrightPackage The ifBrightPackage interface provides the following: • Unpack(path As String) As Void: Extracts the zip file to the specified destination path. Providing a destination path of "SD:/" will wipe all preexisting files from the card and extract the .zip contents to the root folder. • SetPassword(password As String) As Void: Provides the password specified when the .zip file was created. roBrightPackage supports AES 128 and 256 bit encryption, as generated by WinZip. • • GetFailureReason() As String UnpackFile(a As String, b As String) As Boolean Note: ifBrightPackage is a legacy interface. We recommend you use roAssetPool instead to achieve better functionality. Example: package = CreateObject("roBrightPackage", "newfiles.zip") 112 package.SetPassword("test") package.Unpack("SD:/") Using roBrightPackage to distribute new content BrightSign checks storage devices for autorun scripts in the following order: 1. External USB devices 1 through 9 2. SD 3. µSD In addition to looking for autorun.brs scripts, BrightSign players look for autorun.zip files that contain the script name autozip.brs. If autozip.brs is encrypted, then the player 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.brs file is found, and autozip.bas is decrypted, then the player will execute the autozip.brs file. The autozip.brs file cannot reference any external files, as it is the only file to be automatically uncompressed by a BrightSign player prior to execution. The autozip.brs script unpacks the contents of the autorun.zip file to an installed storage device and reboots to complete the update. Example: ' Content update application r=CreateObject("roRectangle", 20, 668, 1240, 80) t=CreateObject("roTextWidget",r,1,2,1) r=CreateObject("roRectangle", 20, 20, 1200, 40) 113 t.SetSafeTextRegion(r) t.SetForegroundColor(&hff303030) t.SetBackgroundColor(&hffffffff) t.PushString("Updating content from USB drive, please wait...") package = CreateObject("roBrightPackage", "autorun.zip") package.SetPassword("test") package.Unpack("SD:/") package = 0 t.Clear() t.PushString("Update complete - remove USB drive to restart.") while true sleep(1000) usb_key = CreateObject("roReadFile", "USB1:/autorun.zip") if type(usb_key) <> "roReadFile" then a=RebootSystem() endif usb_key = 0 end while 114 roDiskErrorEvent This object is returned while waiting on a message port that is connected to an roDiskMonitor object. Interfaces: ifUserData, ifDiskErrorEvent The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifDiskErrorEvent interface provides the following: • GetDiskError() As Object: Returns an roAssociativeArray that contains the following: Key source Type Description roString The error type time roDateTime The time at which the error occurred (with millisecond accuracy) device roString The internal name for the device generating the error error roString A description of the error (e.g."Timeout") param roString The error parameter (use depends on type of error; e.g. the sector number) Example: aa = msgp.GetDiskError() report = "Time: " + aa["Time"] + "Error: " + aa["source"] + " " + aa["error"] + " " + aa["device"] + " " + aa["param"] Note: This example uses an implicit conversion of roDateTime. You could also use roDateTime.GetString(). 115 roDiskMonitor This object provides access to low-level information about disk errors. It provides an event-based interface that delivers roDiskErrorEvent objects via roMessageport. Error messages are held for five seconds before delivery to minimize the chance of spurious error reports. Errors are not reported if the disk is removed during this five second interval because disk-removal detection takes several seconds. This allows for long-term monitoring of occasional media errors. This object uses the ifSetMessagePort interface to select the event destination. Object Creation: roDiskMonitor is created with no parameters. CreateObject("roDiskMonitor") Interfaces: ifSetMessagePort, ifUserData The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object Example: diskmon=CreateObject("roDiskMonitor") msgp=CreateObject("roMessagePort") 116 diskmon.Setport(msgp) 117 roHashGenerator This object provides an API for generating a variety of message digests. Object Creation: The hash algorithm is specified when creating the roHashGenerator object. CreateObject("roHashGenerator", algorithm As String) The algorithm parameter accepts the following strings: • • • • • • SHA256 SHA384 SHA512 SHA1 MD5 CRC32 Note: CRC32 is only available on firmware versions 4.4.x or later. Interfaces: ifHashGenerator The ifHashGenerator interface provides the following: • Hash(obj As Object) As Object: Hashes the payload, which can be supplied in the form of a string (or any object implementing ifString) or an roByteArray. The hash is returned as an roByteArray. • • • SetHmacKey(a As Dynamic) As Boolean: SetObfuscatedHmacKey(a As String) As Boolean: GetFailureReason() As String: 118 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") Interfaces: ifRegistry The ifRegistry interface provides the following: • • GetSectionList() As roList: Returns a list with one entry for each registry section. Delete(section As String) As Boolean: Deletes the specified section and returns an indication of success. • Flush As Boolean: Flushes the registry out to persistent storage. 119 roRegistrySection This object represents a section of the registry, enabling the organization of settings within the registry. It allows the section to be read or written. This object must be supplied with a "section" name upon creation. CreateObject("roRegistrySection", section As String) Interfaces: ifRegistrySection The ifRegistrySection interface provides the following: • Read(key As String) As String: Reads and returns the value of the specified key. Performing Read() on an entry that does not exist, or on a key within a section that does not exist, will return an empty string (""). • • • • • Write(key As String, value As String) As Boolean: Replaces the value of the specified key. Delete(key As String) As Boolean: Deletes the specified key. Exists(key As String) As Boolean: Returns True if the specified key exists. Flush() As Boolean: Flushes the contents of the registry out to persistent storage. GetKeyList() As roList: Returns a list containing one entry per registry key in this section. Example: registrySection = CreateObject("roRegistrySection", "widget-usage") ' An empty entry will read as an empty string and therefore be converted to zero. hits = val(registrySection.Read("big-red-button-hits")) hits = hits + 1 registrySection.Write("big-red-button-hits", strI(hits)) 120 Writes do not always take effect immediately to prevent the system from exceeding the maximum number of writes on the onboard persistent storage. At most, 60 seconds after a write to the registry, the newly written data will be automatically written out to persistent storage. If, for some reason, the change must be written immediately, then one of the flush functions should be called. Changes are automatically written prior to exiting the application. 121 roSqliteDatabase This is the main SQLite object that "owns" the database. You can create as many of these objects as you need. Interfaces: ifSqliteDatabase, ifSetMessagePort The ifSqliteDatabse interface provides the following: • Open(path As String) As Boolean: Opens an existing database file. This method returns True upon success. • Create(path As String) As Boolean: Creates a new, empty database file. This method returns True upon success. • • Close(): Closes an open database. CreateStatement(sql_text As String) As Object: Creates a new roSqlLiteStatement object using the specified SQL string. • RunBackground(sql_text As String, associative_array As Object) As Integer: Runs the specified SQL statement in the background and binds variables using the passed roAssociativeArray. SetMemoryLimit(limit As Integer): Sets the "soft" memory limit under which SQLite will attempt to remain (see the SQLite documentation for details). Note: The SetMemoryLimit()method set global parameters. It must, therefore, be called before any other calls are • made on the database object. • SetTempDirectory(unix_path As String): Sets the temporary directory (specified as a Unix-style path) that SQLite should use. This method will be deprecated in firmware versions 4.8.x and removed from BrightScript in versions 4.9.x. The ifSetMessagePort interface provides the following: • SetPort(a As Object) 122 Example: Creating a Database db = CreateObject("roSqliteDatabase") print db openResult = db.Create("SD:/test.db") if openResult print "Created OK" else print "Creation FAILED" end endif Example: Creating a Table in a Database createStmt = db.CreateStatement("CREATE TABLE playback (md5 text PRIMARY KEY, path PATH, playback_count INT);") print createStmt if type(createStmt) <> "roSqliteStatement" then print "We didn't get a statement returned!!" end endif sqlResult = createStmt.Run() 123 print sqlResult if sqlResult = SQLITE_COMPLETE print "Table Created OK" else print "Table Creation FAILED" endif createStmt.Finalise() 124 roSqliteEvent This event object is returned when a RunBackground() operation is called by the associated roSqliteDatabase object. Interfaces: ifSqliteEvent The ifSqliteEvent interface provides the following: • • GetTransactionId() As Integer: Returns an integer that matches the result of the originating RunBackground() operation. GetSqlResult() As Integer: The result code returned by the roSqlLiteStatement.Run() method. 125 roSqliteStatement This object is created by calling the CreateStatement() method on an roSqliteDatabase object. Interfaces: ifSqliteStatement The ifSqliteStatement interface provides the following: Note: All bind methods return True upon success. • BindByName(associative_array As Object) As Boolean: Binds the SQL variable(s) using the names contained in the SQL statement. • BindByOffset(associative_array/enumerable As Object) As Boolean: Binds the SQL variable(s) using the index contained in the SQL statement. If passed an associative array, this method will convert the keys of the associative array into numeric offsets when binding. If passed an enumerable object (e.g. roArray), it will bind the values of the enumerable in the order that they are stored. • BindText(variable/index As Object, value As String) As Boolean: Binds the SQL variable indicated by the name or index parameter to the passed string value. • BindInteger(variable/index As Object, value As Integer) As Boolean: Binds the SQL variable indicated by the name or index parameter to the passed integer value. • Run() As Integer: Runs the SQL statement immediately and waits for the integer result. The following are possible integer result codes: o 100: Statement complete o 101: Busy o 102: Rows available • RunBackground() As Integer: Runs the SQL statement in the background. You can use roSqliteDatabase.SetPort() to set a message port that will receive an roSqliteEvent message at a later point. The RunBackground() call will result in an integer transaction ID, which will appear in the roSqliteEvent message that matches the transaction. 126 • GetData() As Object: Returns an associative array of name/value pairs that are available after a SELECT (or similar) operation. • Finalise(): Finalizes the statement. This method should be applied to statements before the parent database is closed. The object should not be used after this method is called. Also note that objects are automatically finalized when they are deleted. Example: Inserting into a Table Using BindByName() insertStmt = db.CreateStatement("INSERT INTO playback (md5,path,playback_count) VALUES(:md5_param,:path_param,:pc_param);") print insertStmt if type(insertStmt) <> "roSqliteStatement" then print "We didn't get a statement returned!!" end endif params = { md5_param: "ABDEF12346", path_param: "/foo/bar/bing/bong", pc_param: 11 } bindResult = insertStmt.BindByName(params) if bindResult print "BindByName OK" else print "BindByName FAILED" end endif 127 sqlResult = insertStmt.Run() print sqlResult if sqlResult = SQLITE_COMPLETE print "Table Insertion OK" else print "Table Insertion FAILED" endif insertStmt.Finalise() Example: Inserting into a Table Using BindByOffset() insertStmt = db.CreateStatement("INSERT INTO playback (md5,path,playback_count) VALUES(?,?,?);") print insertStmt if type(insertStmt) <> "roSqliteStatement" then print "We didn't get a statement returned!!" end endif params = CreateObject("roArray", 3, false) params[ 0 ] = "ABDEF12345" 128 params[ 1 ] = "/foo/bar/bing/bong" params[ 2 ] = 10 bindResult = insertStmt.BindByOffset(params) if bindResult print "BindByOffset OK" else print "BindByOffset FAILED" end endif sqlResult = insertStmt.Run() print sqlResult if sqlResult = SQLITE_COMPLETE print "Table Insertion OK" else print "Table Insertion FAILED" endif insertStmt.Finalise() Example: Inserting into a Table in the Background ' This examples assume you have set a message port on your roSqliteDatabase instance 129 ' insertStmt = db.CreateStatement("INSERT INTO playback (md5,path,playback_count) VALUES(:md5_param,:path_param,:pc_param);") print insertStmt if type(insertStmt) <> "roSqliteStatement" then print "We didn't get a statement returned!!" end endif params = { md5_param: "ABDEF12348", path_param: "/foo/bar/bing/bong", pc_param: 13 } bindResult = insertStmt.BindByName(params) if bindResult print "BindByName OK" else print "BindByName FAILED" end endif expectedId = insertStmt.RunBackground() e = mp.WaitMessage(10000) if e <> invalid then 130 if type(e) = "roSqliteEvent" then transId = e.GetTransactionId() sqlResult = e.GetSqlResult() print transId print sqlResult if transId <> expectedId then print "Incorrect transaction Id" end endif if sqlResult <> SQLITE_COMPLETE then print "SQL Insertion Failed" end endif else print "RunBackground() - Wrong event - FAILED" end endif else print "RunBackground() - No Response - FAILED" end endif ' You don't need to call Finalise() since that'll be done by the background processor. Example: Querying from a Table selectStmt = db.CreateStatement("SELECT * FROM playback;") 131 if type(selectStmt) <> "roSqliteStatement" then print "We didn't get a statement returned!!" end endif sqlResult = selectStmt.Run() print sqlResult while sqlResult = SQLITE_ROWS resultsData = selectStmt.GetData() print resultsData; sqlResult = selectStmt.Run() end while selectStmt.Finalise() 132 roStorageAttached, roStorageDetached Interfaces: ifString, ifStringOps The ifString interface provides the following: • • GetString() As String SetString(a As String) The ifStringOps interface provides the following: • • • • • • • • • • • • • • SetString(a As String, b As Integer) AppendString(a As String, b As Integer) Len() As Integer GetEntityEncode() As String Tokenize(a As String) As Object Trim() As String ToInt() As Integer ToFloat() As Float Left(a As Integer) As String Right(a As Integer) As String Mid(a As Integer) As String Mid(a As Integer, b As Integer) As String Instr(a As String) As Integer Instr(a As Integer, b As String) As Integer 133 roStorageHotplug This object provides roStorageAttached messages when storage devices appear and roStorageDetached messages when storage devices disappear. Currently, only external USB devices are supported, and there is no way to poll for media. Object Creation: roStorageHotplug is created with no parameters. CreateObject("roStorageHotplug") Interfaces: ifSetMessagePort The ifSetMessagePort interface provides the following: • SetPort(a As Object) In order to avoid race conditions at startup, you should check for any storage devices that might have existed prior to the message port being set. We recommend doing this after the object is created and the message port is set, but before instructing the script to wait for any events. Example Sub Main() mp = CreateObject("roMessagePort") sh = CreateObject("roStorageHotplug") gpio = CreateObject("roControlPort", "brightsign") sh.SetPort(mp) gpio.SetPort(mp) 134 finished = false while not finished ev = mp.WaitMessage(0) if type(ev) = "roControlDown" finished = true else if type(ev) = "roStorageAttached" print "ATTACHED "; ev.GetString() else if type(ev) = "roStorageDetached" print "DETACHED "; ev.GetString() else print type(ev) stop end if end while End Sub 135 roStorageInfo This object is used to report storage device usage information. Object Creation: roStorageInfo is created containing the storage device information for the specified path. The path does not need to extend to the root of the storage device. CreateObject("roStorageInfo", path As String) Interfaces: ifStorageInfo The ifStorageInfo interface provides the following: Note: On some filesystems that have a portion of space reserved for the super-user, the following expression may not be true: GetUsedInMegabytes + GetFreeInMegabytes == GetSizeInMegabytes • • GetFailureReason() As String: Yields additional useful information if a function return indicates an error. GetBytesPerBlock() As Integer: Returns the size of a native block on the filesystem used by the specified storage device. • • GetSizeInMegabytes() As Integer: Returns the total size (in mebibytes) of the storage device. GetUsedInMegabytes() As Integer: Returns the amount (in mebibytes) of space currently used on the storage device. • • • Note: This amount includes the size of the pool because this class does not integrate pools into its calculations. GetFreeInMegabytes() As Integer: Returns the available space (in mebibytes) on the storage device. GetFileSystemType() As String: Returns a string describing the type of filesystem used on the specified storage. Potential values are fat12, fat16, fat32, ext3, ntfs, hfs, Hfsplus. GetStorageCardInfo() As Object: Returns an associative array containing details of the storage device hardware (a memory card, for example). For SD cards, the returned data may include the following: 136 sd_mfr_id Int Card manufacturer ID as assigned by the SD Card Association sd_oem_id String Two-character card OEM identifier as assigned by the SD Card Association sd_product_name String Product name, assigned by the card manufacturer (5 bytes for SD, 6 bytes for MMC) sd_spec_vers Int Version of SD spec to which the card conforms sd_product_rev String Product revision assigned by the card manufacturer sd_speed_class String Speed class (if any) declared by the card sd_au_size Int Size of the SD AU in bytes. Example: si=CreateObject("roStorageInfo", "SD:/") Print si.GetFreeInMegabytes(); "MiB free" 137 NETWORKING OBJECTS roAssetCollection This object is used to represent a collection of assets. Object Creation: roAssetCollection is created with no parameters. CreateObject("roAssetCollection") You can populate an asset collection with individual calls to AddAsset() or AddAssets(). You can also populate an asset collection using the roSyncSpec.GetAssets method, as shown below: assetCollection = CreateObject("roAssetCollection") localCurrentSync = CreateObject("roSyncSpec") if localCurrentSync.ReadFromFile("local-sync.xml") then assetCollection = localCurrentSync.GetAssets("download") endif Interfaces: ifAssetCollection, ifInternalAssetCollection The ifAssetCollection interface provides the following: stuff • • GetFailureReason() As String AddAsset(asset_info as Object) As Boolean: Adds a single asset from an associative array. 138 • AddAssets(asset_info_array as Object) As Boolean: Adds multiple assets from an enumerable object (roList or roArray) that contains compatible associative arrays. The associative array contains the following: name String Mandatory The name of the asset. For a file to be realized, it must have a valid filename (i.e. no slashes). link String Mandatory The download location of the asset size Integer/String Optional The size of the asset. Use a string if you want to specify a number that is too large to fit into an integer (this allows file sizes larger than 2 GB). hash String Optional A string in the form of "hash_algorithm:hash". See the next table for change_hint String Optional auth_inherit Boolean Optional auth_user Boolean Optional User to utilize for authentication when downloading only this asset. This automatically disables "auth_inherit". auth_passowr d Boolean Optional Password to use when downloading only this asset. This automatically disables "auth_inherit". Boolean Optional The command to pass any header supplier to roAssetFetcher when fetching this asset. The default is true. details. headers_inhe rit Any string that will change in conjunction with the file contents. This is not necessary if the link or hash is supplied and always changes. Indication of whether or not this asset uses roAssetFetcher authentication information. The default is set to True. Hash algorithms: sha1 If a sha1 is available, you can validate the hash as the file is downloaded. If such a hash is available, it should be used. The link and change_hint properties have no effect on the pool file name, so the file is shared 139 even if it is downloaded from different locations. besha1 (none) This algorithm hashes some of the file along with the file size in order to verify the contents. It also moves the link and change_hint properties into the pool filename. Without any hash, the file cannot be verified as it is downloaded, and the system will rely on the link and change_hint properties to give the pool a unique filename. 140 roAssetFetcher This object contains functions for downloading files to the pool. Object Creation: roAssetFetcher must be passed an roAssetPool object upon creation. CreateObject("roAssetFetcher", pool As Object) Example: Pool = CreateObject("roAssetPool", "pool") Fetcher = CreateObject("roAssetFetcher", Pool) Interfaces: ifAssetFetcher, ifMessagePort, ifUserData The ifAssetFetcher interface provides the following: • • • • • • • • • • • GetFailureReason() As String EnableUnsafeAuthentication(a As Boolean) As Boolean AsyncDownload(a As Object) As Boolean AsyncSuggestCache(a As Object) As Boolean AsyncCancel() As Boolean EnablePeerVerification(a As Boolean) EnableHostVerification(a As Boolean) SetCertificatesFile(a As String) SetUserAndPassword(a As String, b As String) As Boolean AddHeader(a As String, b As String) SetHeaders(a As Object) As Boolean 141 • • • • • • • • SetMinimumTransferRate(a As Integer, b As Integer) As Boolean SetProxy(a As String) As Boolean SetFileProgressIntervalSeconds(a As Integer) As Boolean SetFileRetryCount(a As Integer) As Boolean SetRelativeLinkPrefix(prefix As String) As Boolean BindToInterface(a As Integer) As Boolean EnableUnsafeAuthentication(a As Boolean) As Boolean EnableUnsafeProxyAuthentication(a As Boolean) As Boolean The ifMessagePort interface provides the following: • SetPort(a As Object) The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 142 roAssetFetcherEvent Interfaces: ifAssetFetcherEvent, ifUserData The ifAssetFetcherEvent interface provides the following: • • • • • • GetEvent() As Integer GetName() As String GetResponseCode() As Integer GetFailureReason() As String GetFileIndex() As Integer EnableUnsafeAuthentication(enable As Boolean) As Boolean: Supports basic HTTP authentication if True. HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. The roAssetFetcher object will still prefer the stronger digest HTTP if it is supported by the server. If this method is False (which is the default setting), it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication will fail. • EnableUnsafeProxyAuthentication(enable As Boolean) As Boolean: Supports basic HTTP authentication against proxies if True (which, unlike EnableUnsafeAuthentication(), is the default setting). HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. If this method is False, it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication will fail. The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 143 roAssetFetcherProgressEvent Interfaces: ifAssetFetcherProgressEvent, ifUserData The ifAssetFetcherProgressEvent interface provides the following: • • • • • • GetFileName() As String GetFileIndex() As Integer GetFileCount() As Integer GetCurrentFileTransferredMegabytes() As Integer GetCurrentFileSizeMegabytes() As Integer GetCurrentFilePercentage() As Float The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 144 roAssetPool An instance of roAssetPool represents a pool of files for synchronization. You can instruct this object to populate the pool based on a sync spec and then realize it in a specified directory when required. Object Creation: roAssetPool is created with a single parameter representing the rooted path of the pool. CreateObject("roAssetPool", pool_path As String) Example: pool = CreateObject ("roAssetPool", "SD:/pool") Interfaces: ifAssetPool The ifAssetPool interface provides the following: • • GetFailureReason() As String ProtectAssets(name As String, collection As Object) As Boolean: Requests that the files specified in the "download" section of a sync spec receive a certain amount of protection. Specified files will not be deleted when the system software needs to reduce the size of the pool to make space. • UnprotectAssets(name As String) As Boolean: Removes the protected status placed on the specified files by the ProtectAssets() method. Asset collections are reference counted at the system-software level. As a result, when calling UnprotectAssets(), you must pass the same object that you previously passed to ProtectAssets(). • • • UnprotectAllAssets() As Boolean ReserveMegabytes(a As Integer) As Boolean GetPoolSizeInMegabytes() As Integer 145 • • • • Validate(a As Object, b As Object) As Boolean QueryFiles(a As Object) As Object AssetsReady(collection As Object) As Boolean SetMaximumPoolSizeMegabytes(maximum_size As Integer) As Boolean: Specifies the maximum size, in megabytes, of an roAssetPool instance. 146 roAssetPoolFiles This object works similarly to the roSyncPoolFiles object. Object Creation: roAssetPoolFiles is created with two parameters. CreateObject("roAssetPoolFiles", pool As Object, assets As Object) The "assets" can be either an roAssetCollection or roSyncSpec object. If more than one object requires use of the roAssetCollection object, it will be more efficient to convert roSyncSpec to roAssetCollection by calling GetAssets() once and then passing that collection to all objects requiring it. Interfaces: ifAssetPoolFiles The ifAssetPoolFiles interface provides the following: • • • GetFailureReason() As String: Returns explanatory text if GetPoolFilePath() returns an empty string or GetPoolFileInfo() returns Invalid. GetPoolFilePath(asset_name As String) As String: Looks up the specified file name in the asset collection and uses the information to determine the actual name of the file in the pool. This method returns an empty string if the name is not found in the asset collection, or if the file is not found in the pool. GetPoolFileInfo(asset_name As String) As Object: Looks up the specified file name in the asset collection and returns all available information, including the pool file path, as an associative array. This method returns Invalid if the asset name is not found in the asset collection. If the file is not found in the pool, information from the asset collection will be returned without the pool path. See the table below for a description of assets in the associative array. 147 Field Value Description name String Asset name link String Asset URL size String hash String Hash in algorithm ":" hash format change_hint String Only present if set auth_user String Only present if set auth_password String Only present if set auth_inherit Boolean headers_inherit Boolean probe String Probe data path String Absolute path of the file in the pool (or "invalid" if the file is not in the pool) 148 roAssetRealizer This object contains functions for realizing files. Object Creation: roAssetRealizer requires two parameters upon creation: an roAssetPool object and a destination directory. CreateObject("roAssetRealizer", pool As roAssetPool, destination_directory As String) Example: pool = CreateObject("roAssetPool", "pool") realizer = CreateObject ("roAssetRealizer", pool, "/") Interfaces: ifUserData, ifAssetRealizer The IfUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifAssetRealizer interface provides the following: • • GetFailureReason() As String: Yields additional useful information if a function return indicates an error. EstimateRealizedSizeInMegabytes(spec As Object) As Integer: Returns the estimated amount of space that would be taken up by the specified sync spec. • Realize(spec As Object) As Object: Places the files into the destination directory specified in the sync spec. If the pool does not contain the full set of required files, then this method will immediately fail before any files are changed (this method will always attempt to do as much work as possible before destructively modifying the file 149 system). This method automatically checks the length of the file and any hashes that match the specification. If there is a mistmatch, then the affected file is deleted and realization fails. This method indicates success or failure by returning an roAssetRealizerEvent object. Note: The pool and the destination must be in the same file system. • ValidateFiles(spec As Object, options As Object) As Object: Checks the hash of every file in the spec against the corresponding file in the destination path and returns an associative array containing each mismatched fle name mapped to the reason. The options parameter is an roAssociativeArray, which can currentlysupport a single option: o "DeleteCorrupt": Automatically deletes any files that do not match the expected hash. By default, these hashes are not deleted. 150 roAssetRealizerEvent This event object is returned when the roAssetRealizer.Realize() method is called. It yields information about the success or failure of the realization process. Interfaces: ifAssetRealizerEvent, ifUserData The ifAssetRealizerEvent interface provides the following: • GetEvent() As Integer: Returns an integer value indicating the type of the event: 101 EVENT_REALIZE_SUCCESS The specified sync list was successfully realized. -102 EVENT_REALIZE_INCOMPLETE Realization could not begin because at least one of the required files is not available in the pool. -103 EVENT_REALIZE_FAILED_SAFE Realization has failed. Nothing has been written to the destination, so it is likely safe to continue the realization process. More information is about the failure is available via the GetFailureReason() and GetName() methods. -104 EVENT_REALIZE_FAILED_UNSAFE Realization has failed while running, and changes have been made to destination files. It may not be safe to continue the realization process. More information about the failure is available via the GetFailureReason() and GetName() methods. • • GetName() As String: Retrieves the name of the affected file if the realization process fails. GetResponseCode() As Integer: Retrieves the roUrlTransfer response code associated with the event (if any). • • GetFailureReason() As String: Returns additional information if the realization process fails. GetFileIndex() As Integer: Retrieves the zero-based index number of the the file in the sync spec. The ifUserData interface provides the following: 151 • • SetUserData(a As Object) GetUserData() As Object 152 roDatagramSender, roDatagramReceiver, roDatagramSocket, roDatagramEvent The roDatagramSender and roDatagramReceiver objects allow for simple sending and receiving of unicast and broadcast UDP packets. The roDatagramEvent object can be used to both send and receive UDP packets. roDatagramSender This object allows UDP packets to be sent to a specified destination. Object Creation: roDatagramSender is created with no parameters. CreateObject("roDatagramSender") Interfaces: ifDatagramSender The ifDatagramSender interface provides the following: • SetDestination(destination_address As String, destination_port As Integer) As Boolean: Specifies the destination IP address in dotted quad form along with the destination port. This function returns True if successful. • Send(packet As Object) As Integer: Sends the specified data packet as a datagram. The packet may be a string or an roByteArray. This method returns 0 upon success and a negative error code upon failure. This example script broadcasts a single UDP packet containing "HELLO" to anyone on the network listening on port 21075: sender = CreateObject("roDatagramSender") sender.SetDestination("255.255.255.255", 21075) sender.Send("Hello") 153 roDatagramReceiver This object causes instances of roDatagramEvent to be sent to a message port when UDP packets are received on a specified port. Object Creation: roDatagramReceiver is created with a single parameter: CreateObject("roDatagramReceiver ", port As Integer) The port paremeter specifies the port on which to receive UDP packets. Interfaces: ifIdentity, ifSetMessagePort The ifIdentity interface provides the following: • GetIdentity() As Integer The ifSetMessagePort interface provides the following: • SetPort(a As Object) This example script listens for UDP packets on port 21075: receiver = CreateObject("roDatagramReceiver", 21075) mp = CreateObject("roMessagePort") receiver.SetPort(mp) while true event = mp.WaitMessage(0) if type(event) = "roDatagramEvent" then print "Datagram: "; event endif 154 end while roDatagramSocket This object both sends and receives UDP packets. Use roDatagramSocket if you need the player to communicate using protocols such as SSDP, which only allow a server to respond to the source of a received request. Received packets are delivered to the message port as roDatagramEvent objects. Interfaces: ifUserData, ifMessagePort, ifDatagramSocket, ifIdentity The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifMessagePort interface provides the following: • SetPort(a As Object) The ifDatagramSocket interface provides the following: • GetFailureReason() As String: Returns additional information if the BindToLocalPort or Sendto methods fail. • BindToLocalPort(port As Integer) As Boolean: Binds the socket to the specified local port. Use this method to receive packets sent to a specific port. Alternatively, if you want to receive replies to sent packets (and it doesn’t matter which local port is used), pass a port number of 0, and the player will select an unused port. This method returns True upon success and False upon failure • GetLocalPort() As Integer: Returns the local port to which the socket is bound. Use this method if you passed a port number of 0 to BindToLocalPort and need to determine which port the player has selected. 155 • SendTo(destination_address As String, destination_port As Integer, packet As Object) As Integer: Sends a single UDP packet, which can be an roString or roByteArray, to the specified address and port. This method returns 0 upon success and a negative error code upon failure. • JoinMulticastGroup(address as String) as Boolean: Joins the multicast group for the specified address on all interfaces that are currently up. This method returns True upon success and False upon failure. In the event of failure, GetFailureReason() may provide additional information. To ensure that you are joined on all network interfaces, you should register for roNetworkHotplug events and call the JoinMulticastGroup() method in response to the arrival of new networks. The ifIdentity interface provides the following: • GetIdentity() As Integer roDatagramEvent Interfaces: ifUserData, ifSourceIdentity, ifString, ifDatagramEvent The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifSourceIdentity interface provides the following: • GetSourceIdentity() As Integer The ifString interface provides the following: • GetString() As String The ifDatagramEvent interface provides the following: 156 • • • GetByteArray() as Object: Returns the contents of the packet as an roByteArray. GetSourceHost() as String: Returns the source IP address of the packet in dotted form. GetSourcePort() as Integer: Returns the source port of the packet. 157 roHttpEvent Interfaces: ifHttpEvent, ifUserData The ifHttpEvent interface provides the following: • • • GetFailureReason() As String: Yields additional useful information if a function return indicates an error. SetResponseBodyString(a As String): Sets the response body for an event generated using the following function: roHttpServerAddGetFromEvent. Otherwise, this call is ignored. SetResponseBodyFile(a As String) As Boolean: Sets the name of a file to use as the source response body for an event generated via roHttpServer.AddGetFromEvent. Otherwise, this call is ignored. This function will return False if the file cannot be opened or another failure occurs. Note: The file is read gradually as it is sent to the client. • GetRequestBodyString() As String: Returns the string received if the event was generated via roHttpServer.AddPostToString. Otherwise, an empty string is returned. • GetRequestHeader(a As String) As String: Returns the value of the specified HTTP request header. If the header does not exist, an empty string is returned. • • GetRequestHeaders() As Object: Returns an roAssociativeArray containing all the HTTP request headers. GetRequestParam(a As String) As String: Returns the value of the specified URI parameter. If the parameter does not exist, an empty string is returned. • • GetRequestParams() As Object: Returns an roAssociativeArray containing all the URI parameters. AddResponseHeader(a As String, b As String) As Boolean: Adds the specified HTTP header and value to the response. This function returns True upon success. • AddResponseHeaders(a As Object) As Boolean. Expects to be passed an associative array of header names mapped to header values, which can be of type roString, roInt, or roFloat. Any other value types will cause the request to fail and a subset of headers to possibly be set. This function returns True upon success. 158 • GetRequestBodyFile() As String: Returns the name of the temporary file created if the event is generated via roHttpServer.AddGetFromEvent. Otherwise, this call is ignored. • SendResponse(a As Integer) As Boolean: Sends the HTTP response using the specified HTTP status code. To ensure that the response is sent, this function needs be called once you have finished handling the event. • • GetUrl() As String GetFormData() As Object: Returns an roAssociativeArray containing all the form data. See roHttpServer.AddPostToFormData for more information. The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 159 roHttpServer Interfaces: ifHttpServer, ifSetMessagePort, ifGetMessagePort The ifHttpServer interface provides the following: • • GetFailureReason() As String: Yields additional useful information if an roHttpServer method fails. AddGetFromString(parameters As Object) As Boolean: Causes any HTTP GET requests for the specified URL path to be met directly with the contents of the "body" member of the parameter associative array. The MIME type (and potentially the entire character set) should be specified if the request is expected to come from a web browser. The request is handled entirely within the roHttpServer method; no events are sent to the message port. • AddGetFromFile(parameters As Object) As Boolean: Causes any HTTP GET requests for the specified URL path to be met directly from the specified file. You should always specify the MIME type (and possibly the character set) if you expect the request to come from a web browser. The request is handled entirely within the roHttpServer method; no events are sent to the message port. • AddGetFromEvent(parameters As Object) As Boolean: Requests that an roHttpEvent event be sent to the configured message port. This occurs when an HTTP GET request is made for the specified URL path. • AddPostToString(parameters As Object) As Boolean: Requests that an roHttpEvent event be sent to the configured message port. This occurs when an HTTP POST request is made for the specified URL path. Use roHttpEvent.GetRequestBodyString()to retrieve the posted body. • AddPostToFile(parameters As Object) As Boolean: Requests that, when an HTTP POST request is made to the specified URL path, the request body will be stored in a temporary file according to the following parameters: "destination_directory". When this request is complete, an roHttpEvent event is sent to the configured message port. Use roHttpEvent.GetRequestBodyFile() to retrieve the name of the temporary file. If the file still exists at the time the response is sent, it will be automatically deleted. 160 • • AddPostToFormData(parameters As Object) As Boolean: Requests that, when an HTTP POST request is made to the specified URL path, an attempt be made to store form data (passed as application/x-wwwform-urlencoded or multipart/form-data) in an associative array that can be retrieved by calling roHttpEvent.GetFormData(). AddMethodToString(parameters As Object) As Boolean: Attempts to support an arbitrary HTTP method. The request body is placed in a string and an event is raised. This makes the request body available via the roHttpEvent.GetRequestBodyString() method. A response can be sent in the same manner as AddGettoEvent. The Add handler functions described above take an associative array as the parameter. Members of the associative array specify how the handler behaves. The following table illustrates common members: Name Applies to Value url_path all The path for which the handler will be used user_data GetFromEvent,PostToString, A user-defined value that can be retrieved by calling PostToFile,MethodToString roHttpEvent.GetUserData() all An associative array that contains a mapping between usernames and passwords passwords auth all The authentication type to use when passwords are set. This value can be either "basic" or "digest". The value defaults to digest if not specified. realm all The authentication realm, which will be displayed by web browsers when prompting for a username and password headers GetFromFile An associative array that contains arbitrary headers to be included with the automated response content_type GetFromFile The contents of the "Content-Type" header that is included with the automated response. This may not be set at the same time as the headers member. You can set both the MIME type and character set together (e.g. 161 "text/plain; charset=utf-8") body GetFromString The response body filename GetFromFile The path to the file used for the response body. destination_directory PostToFile The path to the directory used for the temporary file containing the request body. A random filename will be generated automatically. The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifGetMessagePort interface provides the following: • GetPort() As Object 162 roMediaStreamer The current implementation of this object allows an XD player to stream .ts files over UDP and RTP. Additional streaming protocols and media file formats will be added as streaming functionality is developed. Object Creation: roMediaStreamer is created with no parameters. CreateObject("roMediaStreamer") Interfaces: ifMediaStreamer, ifIdentity, ifMessagePort The ifMediaStreamer interface provides the following: • • GetFailureReason() As String SetSource(a As Object) As Boolean: Specifies the source of the stream using standard URI syntax (e.g "file:///data/example.ts"). See the Source Specifications section below for more information about parameters specified in the roString. • SetDestination(a As Object) As Boolean: Specifies the destination and protocol of the stream using URL syntax (e.g. "udp://239.192.0.0.1234/"). To use RTP streaming, replace "udp:" with "rtp:". • Start(associative_array As Object) As Boolean: Begins streaming. There are currently no parameters to pass to this method with an associative array. • Stop() As Boolean: Ends streaming. The ifIdentity interface provides the following: • GetIdentity() As Integer The ifMessagePort interface provides the following: • SetPort(a As Object) 163 Source Specifications The string passed to the roMediaStreamer.SetSource() method can have unique parameters that determine the source type and playback behavior. • Looping: By default, a stream from a media file will not loop when it ends. You can specify a looping parameter at the end of the source string as follows: """file:///data/example.mp4?loop". It is also possible to loop the stream using end-of-stream messages from roMediaStreamerEvent. However, the slightly longer restart gap that results from using BrightScript may cause problems with the streaming client. This is especially true if you attempt to set a new media file source upon looping the function. 164 roMediaStreamerEvent This object is sent by instances of roMediaStreamer. It provides information about the current state of an IP stream being sent by the player. Interfaces: ifUserData, ifMediaStreamerEvent The ifUserData interface provides the following: • • SetUserData(a As Object): GetUserData() As Object: The ifMediaStreamerEvent interface provides the following: • GetEvent() As Integer: Returns an integer describing the status of an roMediaStreamer instance: o 0 – EOS_NORMAL: The end of the stream has been reached without any errors being detected. This signal is not sent if the loop parameter is specified using the roMediaStreamer.SetSource() method. o 1 – EOS_ERROR: The stream has been aborted prematurely because of an error condition. 165 roMimeStream This object passes an MJPEG stream in MIME format to the roVideoPlayer.PlayFile() method. There are some limitations to what MJPEG streams this object will play correctly. roMimeStream has been optimized to play streaming video from a local source with the smallest possible delay. The result is a short buffering window that is not appropriate for playing MJPEG streams from URLs outside of a local network. We are currently optimizing roMimeStream to work with different IP camera brands: see the IP Camera FAQ for more details. Object Creation: To play an RTSP stream, first instantiate an roUrlTransfer object. Then wrap it in an roMimeStream object and pass the PictureStream to PlayFile as follows: u=createobject("roUrlTransfer") u.seturl("http://mycamera/video.mjpg") r=createobject("roMimeStream", u) p=createobject("roVideoPlayer") p.PlayFile({ PictureStream: r }) Interfaces: ifPictureStream, ifMessagePort The ifPictureStream interface provides the following: • GetUrl() As String The ifMessagePort interface provides the following: • SetPort(a As Object) Posts event messages to the attached message port. The event messages are of the type roMimeStreamEvent and will implement the ifInt interface. There are currently two possible event messages: o PICTURE_STREAM_FIRST_PICTURE_AVAILABLE = 0: The first picture is now available for decoding. o PICTURE_STREAM_CONNECT_FAILED: The object is unable to connect to the specified URL. 166 roMimeStreamEvent This object will return an integer corresponding to the event that has occurred: Interfaces: ifInt The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) 167 roNetworkAdvertisement This object is used to advertise services running on a BrightSign player to other devices on the network. The current implementation supports advertising via mDNS (which is part of Zeroconf via Bonjour™). Object creation: CreateObject("roNetworkAdvertisement", advertisement As Object) As Object The advertisement should be provided as an roAssociativeArray containing the following keys: • • name: The service name. This should be a readable string such as "Remote BrightSign Widget Service." type: The service type. This should be a service from the definitive list, formatted in the following manner: "_service._protocol" (for example, "_http._tcp"). • • Port: The port number on which the service runs. _name: Any arbitrary text key preceded by an underscore to avoid conflicts within the roAssociativeArray. Note: The underscore is removed before the record is registered with mDNS. Once the object is created, advertising starts immediately and continues until the object is destroyed (i.e. when it becomes unreferenced). Interfaces: None Example di = CreateObject("roDeviceInfo") props = { name: "My Hoopy Service", type: "_http._tcp", port: 8080, _serial: di.GetDeviceUniqueId() } advert = CreateObject("roNetworkAdvertisement", props) 168 ... ' Stop advertising advert = invalid 169 roNetworkAttached, roNetworkDetached roNetworkAttached This object implements ifInt to report the index of the attached network interface. Instances of this object are posted by roNetworkHotplug when a configured network connection becomes available. Note: It may take some time after the cable is inserted for this to take place. Interfaces: ifInt, ifIntOps The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifIntOps interface provides the following: • ToStr() As String roNetworkDetached This object implements ifInt to report an index of the detached network interface. Instances of this object are posted by roNetworkHotplug when a configured network connection becomes unavailable. The interfaces and methods for roNetworkDetached are identical to those outlined for roNetworkAttached above. 170 roNetworkConfiguration This object provides various interfaces for configuring the network interfaces on a BrightSign player. Object creation: roNetworkConfiguration is created with a single parameter. CreateObject("roNetworkConfiguration", network_interface as Integer) The network_interface parameter is used to distinguish between the following: • • 0 for the Ethernet port (if available) on the rear of the BrightSign player. 1 for the optional internal Wi-Fi. Note: Some of the settings are specific to the network interface, while others are used by the BrightSign host for all network interfaces. Interfaces: ifNetworkConfiguration, ifWiFiConfiguration, ifMessagePort, ifUserData The ifNetworkConfiguration interface provides the following: Note: "Set" methods do not take effect until Apply() is called. • SetupDWS(settings As roAssociativeArray) As Boolean: Enables the Diagnostic Web Server (DWS). Settings for the DWS are specified in an associative array that can have the following properties: o port: The port number of the Diagnostic Web Server, located at the IP address of the player. Setting this value to "default" will make the DWS accessible on the default port. Specifying only this parameter in the associative array is equivelant to enabling the DWS without password protection. o password: An obfuscated password for the DWS. This method uses digest access authentication. Specifying this parameter without setting a port number will make the DWS accessible on the default port. 171 o open: An unobfuscated password for the DWS. This method uses digest access authentication. Specifying this parameter without setting a port number will make the DWS accessible on the default port. o basic: A flag indicating whether basic authentication should be used or not. Setting this parameter to True allows the password set with the open parameter to be validated using basic authentication, rather than digest access authentication. This option allows for backwards compatibility with older platforms; most, if not all, modern browsers require basic authentication to be disabled in order to communicate with the DWS. • • • • • Note: The user name is "admin" for all authentication configurations. GetClientIdentifier() As String GetProxy() As String SetClientIdentifier(a As String) As Boolean SetObfuscatedWiFiPassphrase(a As String) As Boolean SetInboundShaperRate(rate As Integer) As Boolean: Sets the bandwidth limit for inbound traffic in bits per second. For the default bandwidth limit, pass -1 to the method; for no bandwidth limit, pass 0 (though these two settings are functionally the same). You will need to call Apply() for these setting to take effect, and changing these settings at any time will cause the network interface to be taken down and reinitialized. Note: Because of overhead on the shaping algorithm, attempting to limit the bandwidth at rates greater than approximately 2Mbit/s will reduce speeds to less than the specified rate. • SetRoutingMetric(a As Integer) As Boolean: Configures the metric for the default gateway on the current network interface. Routes with lower metrics are preferred over routes with higher metrics. This function returns True upon success. • SetDHCP() as Boolean (interface): Enables DHCP and disables all other settings. This function returns True if successful. • • • SetIP4Address(ip As String) As Boolean (interface) SetIP4Netmask(netmask As String) As Boolean (interface) SetIP4Broadcast(broadcast As String) As Boolean (interface) 172 • SetIP4Gateway(gateway As String) As Boolean (interface): Sets the IPv4 interface configuration. All values must be specified explicitly. Unlike the ifconfig shell command, there is no automatic inference. The parameter is a string dotted decimal quad (i.e. "192.168.1.2" or similar). It returns True upon success. Example: nc.SetIP4Address("192.168.1.42") nc.SetIP4Netmask("255.255.255.0") nc.SetIP4Broadcast("192.168.1.255") nc.SetIP4Gateway("192.168.1.1") • SetWiFiESSID(essid as String) as Boolean (interface): Configures the name of the wireless network to connect to. It returns True on success. • SetWiFiPassphrase(passphrase as String) as Boolean: Configures the passphrase or key for the wireless network. It returns True if successfully set. • SetDomain(domain As String) As Boolean (host): Sets the device domain name. This will be appended to names to fully qualify them, though it is not necessary to call this. This method returns True on success. Example: nc.SetDomain("brightsign.biz") • AddDNSServer(server As String) (host): Adds another server to the list when the object is created and there are no DNS servers. There is currently a maximum of three servers, but adding more will not cause any errors. This method returns True on success. There is no way to remove all the servers; it will be easier to recreate the object instead. • • GetFailureReason() As String: Returns additional information when a member function returns False. Apply() As Boolean: Applies the requested changes to the network interface. This may take several seconds to complete. 173 • SetTimeServer(time_server As String) As Boolean (host): Sets the default time server, which is "time.brightsignnetwork.com". You can disable the use of NTP by calling SetTimeServer(""). You can use URL syntax to specify that the player use an HTTP or HTTPS server to synchronize the clock. The following are valid time server addresses: o http://time.brightsignnetwork.com/ o https://time.brightsignnetwork.com/ o ntp://time.brightsignnetwork.com/ o time.brightsignnetwork.com Note: The last two addresses are equivalent. • • GetTimeServer() As String (host): Retrieves the time server currently in use. SetHostName(name as String) as Boolean (host): Sets the device host name. If no host name has been explicitly set, then a host name is automatically generated based on the device serial number. Passing an empty string to this method resets the device host name to its automatically generated value. • • GetHostName() As String (host): Retrieves the host name currently in use. SetProxy(proxy as String) As Boolean (host): Sets the name or address of the proxy server used for HTTP and FTP requests. This should be in the form of "http://user:password@hostname:port". It can contain up to four "*" characters, which are each replaced with one octet from the current IP address. For example, if the IP address is currently 192.168.1.2, and the proxy is set to "proxy-*-*", then the player will attempt to use a proxy named "proxy-192.168". • GetCurrentConfig() As Object: Retrieves the entire current configuration as an associative array containing the following members: metric Integer Interface Returns the current routing metric for the interface. See SetRoutingMetric for more details. dhcp Boolean Interface Returns True if the system is currently configured to use DHCP. Returns False otherwise. 174 hostname String Host The currently configured host name mdns_hostname String Host The Zeroconf host name currently in use. This may be longer than the host name if there is a collision on the current network. ethernet_mac String Interface The Ethernet MAC address ip4_address String Interface The current IPv4 address. If none is currently set, the string will be empty. ip4_netmask String Interface The current IPv4 network mask. If none is currently set, the string will be empty. ip4_broadcast String Interface The current IPv4 broadcast address. If none is currently set, the string will be empty. ip4_gateway String Interface The current IPv4 gateway address. If none is currently set, the string will be empty. domain String Host The current domain suffix dns_servers roArray of Strings Host The currently active DNS servers time_server String Host The current time server configured_proxy String Host The currently configured proxy. This may contain magic characters as explained under SetProxy above. current_proxy String Host The currently active proxy. Any magic characters will have been replaced as explained under SetProxy above. 175 shape_inbound Integer type String Interface Either "wired" or "wifi" link Boolean Interface Indicates whether the network interface is currently connected. wifi_essid String Interface The name of the current Wi-Fi network (if any) wifi_signal Integer Interface An indication of the received signal strength. The absolute value of this field is usually not meaningful, but it can be compared with the reported value on other networks or in different locations. • Interface The current bandwidth shaping for inbound traffic determined by the SetInboundShaperRate() method. TestInterface() As Object: Performs various tests on the network interface to determine whether it appears to be working correctly. It reports the results via an associative array containing the following members: ok Boolean True if the tests find no problems. False if at least one problem was identified. diagnosis String A single-line diagnosis of the first problem identified in the network interface. log roArray containing Strings A complete log of all the tests performed and their results. • ok TestInternetConnectivity() As Object: Performs various tests on the Internet connection (via any available network interface, not necessarily the one specified when the roNetworkConfiguration object was created) to determine whether it appears to be working correctly. It reports the results via an associative array containing the following members: Boolean True if the tests find no problems. False if at least one problem was identified. 176 diagnosis String A single line diagnosis of the first problem identified with the Internet connection. log roArray containing Strings A complete log of all the tests performed and their results. The ifWiFiConfiguration interface provides the following: • ScanWiFi() As Object: Scans for available wireless networks. The results are reported as an roArray containing one or more associative arrays with the following members: essid String Network name bssid String Access point BSSID signal Integer Received signal strength indication. The absolute value of this field is not usually relevant, but it can be compared with the reported value on other networks or in different locations. The ifMessagePort interface provides the following: • SetPort(a As Object): Posts event messages to the attached message port. The ifUserData interface provides the following: • • SetUserData(user_data As Object): Associates an arbitrary object with the roNetworkConfiguration instance that is provided via GetUserData() when an event is generated. GetUserData() As Object: Retrieves the arbitrary object set using SetUserData(). 177 roNetworkHotplug This object can be used to generate events when a network interface becomes available or unavailable. It will post events of the type roNetworkAttached and roNetworkDetached to the associated message port. Note: Reconfiguring a network interface using roNetworkConfiguration may cause it to detach and attach again. To determine which network was attached or detached, the script needs to call roNetworkAttached.GetInt or roNetworkDetached.GetInt. These methods provide an index of the network interface that was attached or detached. Interfaces: ifSetMessagePort The ifSetMessagePort interface provides the following: • SetPort(a As Object) 178 roNetworkStatistics This object allows you to monitor and post how much bandwidth the player is using. Object Creation: roNetworkStatistics is created with a single parameter. CreateObject("roNetworkStatistics", network_interface as Integer) The network_interface parameter is used to distinguish between the following: • • 0 for the Ethernet port (if available) on the rear of the BrightSign player. 1 for the optional internal Wi-Fi. Interfaces: ifNetworkStatistics The ifNetworkStatistics interface provides the following: GetTotals() As roAssociativeArray: Yields the total network figures since booting up. GetIncremental() As roAssociativeArray: Yields the total network figures since booting up. Then, every subsequent time this method is called, it will yield the amount each figure has changed since the previous call. Note: If multiple instances of roNetworkStatistics are created, GetIncremental() calls for each instance will track • • changes independently. Both methods return the following statistics as floating point values: o tx_carrier_errors o tx_packets o rx_packets o tx_errors o rx_frame_errors 179 o o o o o o o o o o o tx_bytes rx_errors tx_collisions rx_dropped tx_compressed rx_multicast tx_dropped rx_fifo_errors rx_bytes tx_fifo_errors rx_compressed 180 roRssParser, roRssArticle roRssParser and roRssArticle are used to display an RSS ticker on the screen. Object Creation: roRssParser is created with no parameters. CreateObject("roRssParser") Interfaces: ifRssParser, ifRssArticle roRssParser uses the ifRssParser interface, which provides the following: • • • ParseFile(filename As String) As Boolean: Parses an RSS feed from a file. ParseString(filename As String) As Boolean: Parses an RSS feed from a string. GetNextArticle() As Object: Gets the next article parsed by the RSS parser. The articles are sorted by publication date, with the most recent article first. This returns an roRssArticle object if there is one. Otherwise, an integer is returned. roRssArticle uses the ifRssArticle interface, which provides the following: • • • GetTitle() As String: Returns the title of the RSS item. GetDescription() As String: Returns the content of the RSS item. GetTimestampInSeconds(a As Integer) As Boolean: Returns in seconds the difference in publication date between this RSS item and the most recent item in the feed. The user can utilize this to decide if an article is too old to display. • • • SetTitle(a As String) As Boolean SetDescription(a As String) As Boolean SetTimestampInSeconds(a As Integer) As Boolean 181 Example: Note: For firmware versions 4.7.x and above, if no alpha value is specified when roTextWidget.SetForegroundColor() is called, the text widget area will appear blank. u=CreateObject("roUrlTransfer") u.SetUrl("http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml") u.GetToFile("tmp:/rss.xml") r=CreateObject("roRssParser") r.ParseFile("tmp:/rss.xml") EnableZoneSupport(1) b=CreateObject("roRectangle", 0, 668, 1024, 100) t=CreateObject("roTextWidget", b, 3, 2, 2) t.SetForegroundColor(&hFFD0D0D0) t.Show() a = r.GetNextArticle() while type(a) = "roRssArticle" t.PushString(a.GetDescription()) sleep(1000) a = r.GetNextArticle() end while while true sleep(1000) end while 182 roRtspStream This is a simple object that is passed to the roVideoPlayer.PlayFile() method. There are some limitations to the RTSP streams this object will play correctly. roRtspStream has been optimized to play streaming video from a local source with the smallest possible delay. The result is a short buffering window that is not appropriate for playing RTSP streams from URLs outside of a local network. We are currently optimizing roRtspStream to work with different IP camera brands: see the IP Camera FAQ for more details. Object Creation: To play an RTSP stream, instantiate an roRtspStream object with a URL as its argument. Then pass it to the playfile() method as follows: r=createobject("roRtspStream", "rtsp://172.30.1.194/axis-media/media.amp") p=createobject("roVideoPlayer") p.PlayFile({Rtsp: r}) Interfaces: ifRtspStream, ifMessagePort The ifRtspStream interface provides the following: • GetUrl() As String The ifMessagePort interface provides the following: • SetPort(a As Object): Posts event messages to the attached message port. The event messages are of the type roRtspStreamEvent and will implement the ifInt interface. 183 roRtspStreamEvent This object will return an integer corresponding to the event that has occurred: Interfaces: ifInt The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) 184 roShoutcastStream Object creation: roShoutcastStream takes a URL object, a maximum buffer size (in seconds), and an initial buffering duration (in seconds). CreateObject("roShoutcastStream", url_transfer, buffer size, buffer duration) Interfaces: ifShoutcastStream, ifSetMessagePort, ifSourceIdentity The ifShoutcastStream interface provides the following: • • • • • • • GetUrl() As String GetBufferedDuration() As Integer GetTimeSinceLastData() As Integer GetCurrentMetadata() As String Rebuffer() As Boolean AsyncSaveBuffer(a As String) As Boolean RestartBufferRecord() As Boolean The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifSourceIdentity interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity(a As Integer) 185 roShoutcastStreamEvent Interfaces: ifInt, ifSourceIdentity The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifSourceIdentity interface provides the following: • • GetSourceIdentity() As Integer SetSourceIdentity(a As Integer) 186 roSnmpAgent When this object is created, it starts an SNMP process that handles some standard SNMP MIBs such as system uptime. Prior to starting the roSnmpAgent, you can register other OIDs for handling. You can set and retrieve these both by an SNMP client and by the script. OID values are retrieved by an SNMP client without script interaction, and setting these values simply generates an event from roSnmpAgent stating that it has been changed. The script event handler can then retrieve new values and take appropriate action. Interfaces: ifSnmpAgent, ifSetMessagePort The ifSnmpAgent interface provides the following: • • • • AddOidHandler(a As String, b As Boolean, c As Object) As Boolean GetOidValue(a As String) As Object SetOidValue(a As String, b As Object) As Boolean Start() As Boolean The ifSetMessagePort interface provides the following: • • • SetPort(a As Object) Interface ifGetMessagePort: GetPort() As Object 187 roSnmpEvent Interfaces: ifString, ifStringOps The ifString interface provides the following: • • GetString() As String SetString(a As String) The ifStringOps interface provides the following: • • • • • • • • • • • • • • SetString(a As String, b As Integer) AppendString(a As String, b As Integer) Len() As Integer GetEntityEncode() As String Tokenize(a As String) As Object Trim() As String ToInt() As Integer ToFloat() As Float Left(a As Integer) As String Right(a As Integer) As String Mid(a As Integer) As String Mid(a As Integer, b As Integer) As String Instr(a As String) As Integer Instr(a As Integer, b As String) As Integer 188 roStreamByteEvent Interfaces: ifInt, ifUserData The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifUserdata interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 189 roStreamConnectResultEvent This event is sent to a message port associated with an roTCPStream object when an AsyncConnectTo() request has been completed or has failed. Interfaces: ifInt, ifUserData The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 190 roStreamEndEvent Interfaces: ifInt, ifUserData The ifInt interface provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 191 roStreamLineEvent Interfaces: ifUserData, ifString The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifString interface provides the following: • • GetString() As String SetString(a As String) 192 roSyncManager This object provides advanced synchronization capabilities for video walls and other deployments that require closely calibrated interaction among players. roSyncManager handles all network traffic for master/slave synchronization, including the network clock. Multiple synchronization groups are allowed on the same local network; synchronization groups can be differentiated during the object creation process. Object Creation: roSyncManager is created with a single set of parameters. CreateObject("roSyncManager", parameters as roAssociativeArray) The associative array can have the following members: • Domain: A string that is used to distinguish among different synchronization groups (e.g. video walls) sharing a network. The default string is "BrightSign". • MulticastAddress: A string specifying to which multicast address synchronization messages are communicated. The default address is "224.0.126.10". • MulticastPort: A string specifying to which multicast port synchronization messages are communicated. The default port is "1539". Interfaces: ifMessagePort, ifSyncManager The ifMessagePort interface provides the following: • SetPort(port as Object) The ifSyncManager provides the following: • SetMasterMode(master_mode As Boolean) As Boolean: Specifies whether the unit is running the master instance of roSyncManager. 193 • Synchronize(identifier As String, ms_delay As Integer) As Object: Configures how the master unit will broadcast the time-stamped event to other players. It continues to send out this event every second to allow slave units that are powered on late to catch up. The network message contains the sync ID, as well as the domain and a timestamp. The timestamp is created at the point when this method is called; however, it can be offset by passing a non-zero ms_delay, allowing synchronization points to be set slightly in the future and giving the client enough time to switch video files and perform other actions. The event is returned from the call so that the caller can access the timestamp. The identifier parameter allows scripts to pass a filename, or some other useful marker, to the slave units as part of the synchronization message. Note: Because synchronization can involve slave units seeking to catch up with the playback of a master unit, we recommend using the more efficient MOV/MP4 container format when synchronizing video files. Currently, there are two objects that can accept synchronization parameters: The roVideoPlayer PlayFile() call accepts the parameters provided by ifSyncManagerEvent messages, while the roImagePlayer DisplayFile() and PreloadFile() calls accept SyncIsoTimestamp as an associative array. To synchronize image playback, an roImagePlayer object will simply delay the transition thread prior to running the transition. If there is a separate call for DisplayFile(), then the transition will be cancelled and the image will be displayed immediately (as with nonsynchronized DisplayFile() calls). Example ' Create a sync manager with default address and port. aa1=CreateObject("roAssociativeArray") aa1.Domain = "BS1" s=CreateObject("roSyncManager", aa1) p=CreateObject("roMessagePort") s.SetPort(p) 194 ' Create a video player - we're going to play a seamlessly looped file v=CreateObject("roVideoPlayer") v.SetLoopMode(1) ' THIS SECTION IS ONLY DONE BY THE MASTER ' We're the master unit - send out a synchronize event saying that we're starting. ' playback 1000ms from now s.SetMasterMode(1) msg = s.Synchronize("Blah1", 1000) ' THIS SECTION IS ONLY DONE BY THE SLAVE ' We're a slave unit, and we're sitting waiting for a sync message. msg=Wait(4000, p) ' EVERYONE DOES THE REST aa=CreateObject("roAssociativeArray") aa.Filename = "Text_1.mov" aa.SyncDomain = msg.GetDomain() aa.SyncId = msg.GetId() aa.SyncIsoTimestamp = msg.GetIsoTimestamp() v.PlayFile(aa) 195 roSyncManagerEvent These events are generated on slave units in response to roSyncManager.Synchronize() calls from the master unit. The roSyncManager on each slave unit will handle message duplicates, so the script will receive the sync message only once during normal operations. If the slave unit is already booted up, then the event will arrive from the first network event generated by roSyncManager.Synchronzie(). On the other hand, if the slave unit is booted up while the master is in the middle of playing a video file, then one of the message resends (generated at one second intervals by the master unit) will trigger the event. The script passes on the data from the event to the PlayFile() command of the video player or the DisplayFile() command of the image player, which will then determine how far forward in the file it needs to seek. Interfaces: ifUserData, ifSyncManagerEvent The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifSyncManagerEvent interface provides the following: • GetDomain() As String: Returns the domain of the sync group, which is specified during creation of the roSyncManager object on the master unit. • • GetId() As String: Returns the identifier of the event. GetIsoTimestamp() As String: Returns the timestamp of the event in ISO format. 196 roSyncSpec This object represents a parsed sync spec. It allows you to retrieve various parts of the specification with methods. Interfaces: ifSyncSpec, ifInternalSyncSpec, ifInstanceFromStream The ifSyncSpec interface provides the following: • • GetFailureReason() As String: Returns information if an roSyncSpec method indicates failure. ReadFromFile(filename As String) As Boolean: Populates the sync spec by reading the specified file. This method returns True upon success and False upon failure. • ReadFromString(spec As String) As Boolean: Populates the sync spec by reading the passed string. This method returns True upon success and False upon failure. • WriteToFile(filename As String) As Boolean: Writes out the current sync spec to the specified file. Because the XML is regenerated, it is possible this file may not be textually identical to the specification that was read. This method returns True upon success and False upon failure. • WriteToString() As String: Writes out the current sync spec to a string and returns it. This method returns an empty string if the write operation fails. • GetMetadata(section As String) As roAssociativeArray: Returns an roAssociativeArray object containing the information stored in the specified metadata section of the sync spec (typically "client" or "server"). This method returns 0 if the read operation fails. • LookupMetadata(section As String, field As String) As String: Provides a shortcut for looking up specified metadata items in the specified section without needing to create a temporary roAssociativeArray object. This method returns an empty string if the read operation fails. • GetFileList(section As String) As roList: Returns an roList object containing roAssociativeArray objects for each file in the specified section of the sync spec. This method returns Invalid if the read operation fails. 197 • GetFile(section As String, index As Integer) As roAssociativeArray: Returns an roAssociativeArray object for the file in the specified section and at the specified index. This method returns Invalid if the read operation fails. • • GetName() As String: Returns the name supplied for the sync spec in the XML element. EqualTo(other As roSyncSpec) As Boolean: Compares the contents of the roSyncSpec object with another roSyncSpec object. This method compares the parsed contents of each sync spec rather than the XML files themselves. • VerifySignature(signature as String, obfuscated_passphrase as String) As Boolean: Deobfuscates the passphrase and uses it to verify the signature of the sync spec. This method returns True upon success and False upon failure. • • • FilterFiles(a As String, b As Object) As Object FilesEqualTo(a As Object) As Boolean GetAssets(a As String) As Object 198 roTCPConnectEvent The event is posted when a new connection is made to an roTCPServer port. The normal response to receiving such an event is to create a new roTCPStream object and pass the event to its AcceptFrom call. Interfaces: ifUserData, ifSocketInfo, ifInternalGetTCPStream The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifSocketInfo interface provides the following: • GetSourceAddress() As String: Returns the IP address of the remote end of the TCP connection. 199 roTCPServer Interfaces: ifTCPServerInstance, ifUserData The ifTCPServerInstance interface provides the following: • • • GetFailureReason() As String: Yields additional useful information if an roTCPServer method fails. SetPort(port As Object): Sets the message port that will receive events from an roTCPServer instance. BindToPort(port As Dynamic) As Boolean: Prepares to accept incoming TCP connections on the specified port. Passing an integer to this method will specify a standard port number. This method can also accept an index of integer interfaces contained within an associative array, which can contain the following members: o -1: Any (this is the default value) o 0: Ethernet o 1: WiFi o 2: Modem o 32767: Loopback (i.e. TCP connections can only be established by internal sources) The ifUserData interface provides the following: • SetUserData(a As Object): Supplies an object that will be provided by every event called by an roTCPServer instance. • GetUserData() As Object 200 roTCPStream Interfaces: ifStreamReceive, ifUserData, ifStreamSend, ifTCPStream The ifStreamReceive interface provides the following: • • • • SetLineEventPort(a As Object) SetByteEventPort(a As Object) SetReceiveEol(a As String) SetMatcher(matcher As Object) As Boolean: Instructs the stream to use the specified matcher. This object returns True if successful. Pass Invalid to this method to stop using the specified matcher. The ifUserData interface provides the following: • SetUserData(a As Object): Supplies an object that will be provided by every event called by an roTCPStream instance. • GetUserData() As Object The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • Flush() The ifTCPStream interface provides the following: 201 • • GetFailureReason() As String: Yields additional useful information if an roTCPStream method fails. ConnectTo(a As String, b As Integer) As Boolean: Connects the stream to the specified host (designated using a dotted quad) and port. The function returns True upon success. • Accept(a As Object) As Boolean: Accepts an incoming connection event. The function returns True upon success. • AsyncConnectTo(a As String, b As Integer) As Boolean: Attempts to connect the stream to the specified host (designated using a dotted quad) and port. The function returns False if this action is immediately impossible (for example, when the specified host is not in the correct format). Otherwise, the function returns True upon success. The connect proceeds in the background, and an roStreamConnectResultEvent is posted to the associated message port when the connect attempt succeeds or fails. 202 roUrlEvent Interfaces: ifInt, ifUserData, ifUrlEvent, ifString, ifSourceIdentity The ifInt interface provides the following: • GetInt() As Integer: Returns the type of event. The following event types are currently defined: transfer complete (1), transfer started (2). Headers are available for suitable protocols (though this is not currently implemented). The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifUrlEvent interface provides the following: • GetResponseCode() As Integer: Returns the protocol response code associated with an event. The following codes indicate success: o 200: Successful HTTP transfer o 226: Successful FTP transfer o 0: Successful local file transfer For unexpected errors, the return value is negative. There are many possible negative errors from the CURL library, but it is often best to look at the text version by calling GetFailureReason. Here are some potential errors. Not all of them can be generated by a BrightSign player: Status Name Description -1 CURLE_UNSUPPORTED_PROTOCOL -2 CURLE_FAILED_INIT 203 -3 -5 -6 -7 -8 CURLE_URL_MALFORMAT CURLE_COULDNT_RESOLVE_PROXY CURLE_COULDNT_RESOLVE_HOST CURLE_COULDNT_CONNECT CURLE_FTP_WEIRD_SERVER_REPLY -9 CURLE_REMOTE_ACCESS_DENIED -11 -13 -14 -15 -17 -18 -19 -21 -22 -23 -25 -26 -27 -28 -30 -31 -33 -34 -35 -36 -37 -38 -39 -41 CURLE_FTP_WEIRD_PASS_REPLY CURLE_FTP_WEIRD_PASV_REPLY CURLE_FTP_WEIRD_227_FORMAT CURLE_FTP_CANT_GET_HOST CURLE_FTP_COULDNT_SET_TYPE CURLE_PARTIAL_FILE CURLE_FTP_COULDNT_RETR_FILE CURLE_QUOTE_ERROR CURLE_HTTP_RETURNED_ERROR CURLE_WRITE_ERROR CURLE_UPLOAD_FAILED CURLE_READ_ERROR CURLE_OUT_OF_MEMORY CURLE_OPERATION_TIMEDOUT CURLE_FTP_PORT_FAILED CURLE_FTP_COULDNT_USE_REST CURLE_RANGE_ERROR CURLE_HTTP_POST_ERROR CURLE_SSL_CONNECT_ERROR CURLE_BAD_DOWNLOAD_RESUME CURLE_FILE_COULDNT_READ_FILE CURLE_LDAP_CANNOT_BIND CURLE_LDAP_SEARCH_FAILED CURLE_FUNCTION_NOT_FOUND A service was denied by the server due to lack of access. When login fails, this is not returned. Failed quote command Failed upload command. Could not open/read from file. The timeout time was reached. FTP PORT operation failed. REST command failed. RANGE command did not work. Wrong when connecting with SSL. Could not resume download. 204 -42 -43 -45 -47 -48 -49 -51 -52 -53 -54 -55 -56 -58 -59 -60 -61 -62 -63 -64 -65 -66 CURLE_ABORTED_BY_CALLBACK CURLE_BAD_FUNCTION_ARGUMENT CURLE_INTERFACE_FAILED CURLE_TOO_MANY_REDIRECTS CURLE_UNKNOWN_TELNET_OPTION CURLE_TELNET_OPTION_SYNTAX CURLE_PEER_FAILED_VERIFICATION CURLE_GOT_NOTHING CURLE_SSL_ENGINE_NOTFOUND CURLE_SSL_ENGINE_SETFAILED CURLE_SEND_ERROR, CURLE_RECV_ERROR CURLE_SSL_CERTPROBLEM CURLE_SSL_CIPHER CURLE_SSL_CACERT CURLE_BAD_CONTENT_ENCODING CURLE_LDAP_INVALID_URL CURLE_FILESIZE_EXCEEDED, CURLE_USE_SSL_FAILED, CURLE_SEND_FAIL_REWIND, CURLE_SSL_ENGINE_INITFAILED -67 CURLE_LOGIN_DENIED -68 -69 -70 -71 -72 -73 -74 -75 CURLE_TFTP_NOTFOUND CURLE_TFTP_PERM CURLE_REMOTE_DISK_FULL CURLE_TFTP_ILLEGAL CURLE_TFTP_UNKNOWNID CURLE_REMOTE_FILE_EXISTS CURLE_TFTP_NOSUCHUSER CURLE_CONV_FAILED CURLOPT_INTERFACE failed. Catch endless re-direct loops. User specified an unknown option. Malformed telnet option. Peer's certificate or fingerprint wasn't verified correctly. When this is a specific error. SSL crypto engine not found. Cannot set SSL crypto engine as default. Failed sending network data. Failure in receiving network data. Problem with the local certificate. Could not use specified cipher. Problem with the CA cert (path?) Unrecognized transfer encoding. Invalid LDAP URL. Maximum file size exceeded. Requested FTP SSL level failed. Sending the data requires a rewind that failed. Failed to initialize ENGINE. User, password, or similar field was not accepted and login failed . File not found on server. Permission problem on server. Out of disk space on server. Illegal TFTP operation. Unknown transfer ID. File already exists. No such user. Conversion failed. 205 -76 CURLE_CONV_REQD -77 -78 CURLE_SSL_CACERT_BADFILE CURLE_REMOTE_FILE_NOT_FOUND -79 CURLE_SSH -80 CURLE_SSL_SHUTDOWN_FAILED Caller must register conversion callbacks using the following URL_easy_setopt options: CURLOPT_CONV_FROM_NETWORK_FUNCTION CURLOPT_CONV_TO_NETWORK_FUNCTION CURLOPT_CONV_FROM_UTF8_FUNCTION Could not load CACERT file, missing or wrong format. Remote file not found. Error from the SSH layer (this is somewhat generic, so the error message will be important when this occurs). Failed to shut down the SSL connection. • • • GetObject() As Object GetFailureReason As String: Returns a description of the failure that occurred. GetSourceIdentity As Integer: Returns a unique number that can be matched with the value returned by roUrlTransfer.GetIdentity to determine where this event came from. • GetResponseHeaders As roAssociativeArray: Returns an associative array containing all the headers returned by the server for appropriate protocols (such as HTTP). The ifString interface provides the following: • GetString As String: Returns the string associated with the event. For transfer-complete AsyncGetToString, AsyncPostFromString, and AsyncPostFromFile requests, this will be the actual response body from the server, truncated to 65,536 characters. The ifSourceIdentity interface provides the following: • GetSourceIdentity As Integer: Returns a unique number that can be matched with the value returned by roUrlTransfer.GetIdentity to determine where this event originated. 206 roUrlStream This object allows playback of content from a URL; the current implementation is only designed to work from local NAS storage. This object is created with an associated roUrlTransfer object, as well as a number of other numeric parameters that define buffer size, etc. The roUrlTransfer object defines the retrieval URL and is documented separately. To use the final object to play back content, you must put the object into an associative array with the parameter name "Url". This array can then be sent to roVideoPlayer.PlayFile() for playback. Interfaces: ifUrlStream The ifUrlStream interface provides the following: • • • • GetUrl() As String GetBufferSize() As Integer GetRewindSize() As Integer GetMinimumFill() As Integer 207 roUrlTransfer This object is used for reading from and writing to remote servers through URLs. Object Creation: roUrlTransfer is created with no parameters. CreateObject("roUrlTransfer") Interfaces: ifUserData, ifIdentity, ifSetMessagePort, ifGetMessagePort, ifUrlTransfer The ifUserData interface provides the following: • • SetUserData(user_data As Object): Associates an arbitrary object with the roUrlTransfer instance that is provided via roUrlEvent.GetUserData() when an event is generated. GetUserData() As Object: Retrieves the arbitrary object set using SetUserData(). The ifIdentity interface provides the following: • GetIdentity As Integer: Returns a unique number that can be used to identify whether events originated from this object. The ifSetMessagePort interface provides the following: • SetPort(port As ifMessagePort) As Void: Sets the message port to which events will be posted for asynchronous requests. The ifGetMessagePort interface provides the following: • GetPort() As Object 208 The ifUrlTransfer interface provides the following: • SetUrl(URL As String) As Boolean: Sets the URL for the transfer request. This function returns False on failure. Use GetFailureReason to learn the reason for the failure. Note When using SetUrl to retrieve content from local storage, you do not need to specify the full file path: SetUrl("file:/example.html"). If the content is located somewhere other than the current storage device, you can specify it within the string itself. For example, you can use the following syntax to retrieve content from a storage device inserted into the USB port when the current device is an SD card: SetUrl("file:///USB1:/example.html"). • AddHeader(name As String, value As String) As Boolean: Adds the specified HTTP header. This is only valid for HTTP URLs. This function returns False on failure. Use GetFailureReason() to learn the reason for the failure. • • • GetToString As String: Connects to the remote service as specified in the URL and returns the response body as a string. This function cannot return until the exchange is complete, and it may block for a long time. Having a single string return means that much of the information (headers, response codes) has been discarded. If you need this information, you can use AsyncGetToString() instead. Note: The size of the returned string is limited to 65,536 characters. GetToFile(filename As String) As Integer: Connects to the remote service as specified in the URL and writes the response body to the specified file. This function does not return until the exchange is complete and may block for a long time. The response code from the server is returned. It is not possible to access any of the response headers. If you need this information, use AsyncGetToFile() instead. AsyncGetToString As Boolean: Begins a "get" request to a string asynchronously. Events 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. 209 • AsyncGetToFile(filename As String) As Boolean: Begins a "get" request to a file asynchronously. Events 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. • Head() As Object: Synchronously perform an HTTP HEAD request and return the resulting response code and headers through an roUrlEvent object. In the event of catastrophic failure (e.g. an asynchronous operation is already active), a null object is returned. • AsyncHead() As Boolean: Begins an ansynchronous HTTP HEAD request. Events will be sent to the message port associated with the object. If the request could not be issued, the method will return False and will not deliver any events. • PostFromString(request As String) As Integer: Uses the HTTP POST method to post the supplied string to the current URL and return the response code. Any response body is discarded. • PostFromFile(filename As String) As Integer: Uses the HTTP POST method to post the contents of the file specified to the current URL and then return the response code. Any response body is discarded. • AsyncPostFromString(request As String) As Boolean: Uses 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. A False return indicates that the request could not be issued and no events will be delivered. • AsyncPostFromFile(filename As String) As Boolean: Uses the HTTP POST method to post the contents of the specified file to the current URL. Events of the type roUrlEvent will be sent to the message port associated with the object A False return indicates that the request could not be issued and no events will be delivered. • SetUserAndPassword(user As String, password As String) As Boolean: Enables HTTP authentication using the specified user name and password. Note that HTTP basic authentication is deliberately disabled due to it being inherently insecure. HTTP digest authentication is supported. • SetMinimumTransferRate(bytes_per_second As Integer, period_in_seconds As Integer) As Boolean: Causes the transfer to be terminated if the rate drops below bytes_per_second when averaged over period_in_seconds. Note that if the transfer is over the Internet, you may not want to set period_in_seconds 210 to a small number in case network problems cause temporary drops in performance. For large file transfers and a small bytes_per_second limit, averaging over fifteen minutes or even longer might be appropriate. • GetFailureReason As String: May provide additional information if any of the roUrlTransfer methods indicate failure. • • SetHeaders(a As Object) As Boolean AsyncGetToObject(type As String) As Boolean: Begins an asynchronious GET request and uses the contents to create an object of the specified type. Events will be sent to the message port associated with the object. If this method returns False, the request could not be issued and no events will be delievered. • • AsyncCancel() As Boolean EnableUnsafeAuthentication(enable As Boolean) As Boolean: Supports basic HTTP authentication if True. HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. The roUrlTransfer object will still prefer the stronger digest HTTP if it is supported by the server. If this method is False (which is the default setting), it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication will fail. • EnableUnsafeProxyAuthentication(enable As Boolean) As Boolean: Supports basic HTTP authentication against proxies if True (which, unlike EnableUnsafeAuthentication(), is the default setting). HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. If this method is False, it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication will fail. • • • • • EnableResume(a As Boolean) As Boolean EnablePeerVerification(a As Boolean) As Boolean EnableHostVerification(a As Boolean) As Boolean SetCertificatesFile(a As String) As Boolean EnableEncodings(a As Boolean) As Boolean: Communicates to the server that the system can accept any encoding that the roUrlTransfer object is capable of decoding by itself. This currently includes "deflate" and "gzip", which allow for transparent compression of responses. Clients of roUrlTransfer see only the decoded data and are unaware of the encoding being used. 211 • • SetUserAndPassword(a As String, b As String) As Boolean Head() As Object: Performs a synchronous HTTP HEAD request and returns the resulting response code and headers through an roURLEvent object. In the event of catastrophic failure (e.g. an asynchronous operation is already active), a null object is returned. • Escape(unescaped As String) As String: Converts the provided string to a URL-encoded string. All characters that could be misinterpreted in a URL context are converted to the %XX form. • • • • Unescape(a As String) As String GetUrl() As String SetProxy(a As String) As Boolean SetTimeout(milliseconds As Integer) As Boolean: Terminates the transfer if the request takes longer than the specified number milliseconds. Note that this includes the time taken by any name lookups, so setting this value too low will cause undesirable results. Passing 0 to the method disables the timeout. This method returns True upon success and False upon failure. In the event of failure, using the GetFailureReason() method may provide more information. If the operation times out, the status return is -28. • • SetUserAgent(a As String) As Boolean PutFromString(a As String) As Integer: Uses the HTTP PUT method to write the supplied string to the current URL and return the response code. Any response body is discarded; use roUrlTransfer.SyncMethod to retrieve the response body. • PutFromFile(a As String) As Integer: Uses the HTTP PUT method to write the contents of the specified file to the current URL and return the response code. Any response body is discarded; use roUrlTransfer.SyncMethod to retrieve the response body. • AsyncPutFromString(a As String) As Boolean: Uses the HTTP PUT method to write the supplied string to the current URL. Events of type roUrlEvent will be sent to the message port associated with the object. A False return indicates that the request could not be issued and no events will be delivered. Any response body is discarded; use roUrlTransfer.AsyncMethod to retrieve the response body. • AsyncPutFromFile(a As String) As Boolean : Uses the HTTP PUT method to write the contents of the specified file to the current URL. Events of type roUrlEvent will be sent to the message port associated with the 212 object. A False return indicates that the request could not be issued and no events will be delivered. Any response body is discarded; use roUrlTransfer.AsyncMethod to retrieve the response body. • Delete() As Object: Uses the HTTP DELETE method to delete the resource at the current URL and return the response code. Any response body is discarded; use roUrlTransfer.SyncMethod to retrieve the response body. • AsyncDelete() As Boolean: Uses the HTTP DELETE method to delete the resource at the current URL. Events of type roUrlEvent will be sent to the message port associated with the object. A False return indicates that the request could not be issued and no events will be delivered. Any response body is discarded; use roUrlTransfer.AsyncMethod to retrieve the response body. • • ClearHeaders(): Removes all headers that would be supplied with an HTTP request. AddHeaders(a As Object) As Boolean: Adds one or more headers to HTTP requests. Pass headers to this object as an roAssociativeArray of name/value pairs. This method returns True upon success and False upon failure. All headers that are added with this method will continue to be sent with HTTP requests until ClearHeaders()is called. • • • • SyncMethod(a As Object) As Object: Performs a synchronous HTTP method request using the specified parameters. If the request is started successfully, then the method returns an roUrlEvent object containing the results of the request. This method returns Invalid if the the request could not be started. In this case, the GetFailureReason() method may provide more information. SetRelativeLinkPrefix(prefix As String) As Boolean: Places the specified prefix in front of the URL if the URL is relative. Use this method to easily make file:/// URLs drive agnostic. BindToInterface(interface As Integer) As Boolean: Ensures that the request only goes out over the specified network interface. By default, the request goes out over the most appropriate network interface (which may depend on the routing metric configured via roNetworkConfiguration). Note that if both interfaces are on the same layer 2 network, this method may not always work as expected due to the Linux weak host model. The default behavior can be selected by passing -1 to the method. This method returns False upon failure. In this case, the GetFailureReason() method may provide more information. AsyncMethod(parameters As Object) As Boolean: Begins an asynchronous HTTP method request using the specified parameters (see below). If the request is started successfully, the method returns True and and will 213 deliver an event. If the request could not be started, then the method returns False and will not deliver an event. If this occurs, you may be able to use the GetFailureReason() method to get more information. The parameters are sepecifed as an associatve array that may contain the following members: Name method Type String Description An HTTP method. Normal values include "HEAD", "GET", "POST", "PUT", and "DELETE". Other values are supported; however, depending on server behavior, they may not work as expected. request_body_string String A string containing the request body. request_body_file String The name of a file that contains the request body response_body_string Boolean If specified and set to True, the response will be stored in a string and provided via the roUrlEvent.GetString() method. response_body_file String The name of the file that will contain the response body. The body is written to a temporary file and then renamed to the specified filename if successful. response_body_resume_file String The name of the file that will contain the response body. For a GET request, a RANGE header is sent based on the current size of the file, which is written in place rather than using a temporary file. response_body_object String Uses the response body to create an object of the specified type. See the entry for AsyncGetToObject() for supported object types. 214 INPUT/OUTPUT OBJECTS roCecInterface This object provides access to the HDMI CEC channel. Object Creation: roCecInterface is created with no parameters. CreateObject("roCecInterface") Interfaces: IfCecInterface, ifSetMessagePort The IfCecInterface interface provides the following: • SendRawMessage(packet As Object) As Void: Sends a message on the CEC bus. The frame data should be provided as an roByteArray, with the destination address in the low 4 bits of the first octet. The high 4 bits of the first octet should be supplied as zero; they will be replaced with the source address. The ifSetMessagePort interface provides the following: • SetPort(a As Object) 215 roCecRxFrameEvent, roCecTxCompleteEvent If an roMessagePort is attached to an roCecInterface instance, it will receive events of type roCecRxFrameEvent and/or roCecTxCompleteEvent. roCecRxFrameEvent Interfaces: ifCecRxFrameEvent The ifCecRxFrameEvent interface provides the following; • GetByteArray() As Object: Returns the message data as an roByteArray. roCecTxFrameEvent Interfaces: ifCecTxCompleteEvent The ifCecTxCompleteEvent interface provides the following: • GetStatusByte() As Integer The currently defined status codes are described below: 0x00 Transmission successful 0x80 Unable to send, CEC hardware powered down 0x81 Internal CEC error 0x82 Unable to send, CEC line jammed 0x83 Arbitration error 216 0x84 Bit-timing error 0x85 Destination address not acknowledged 0x86 Data byte not acknowledged 217 roChannelManager You can use this object to manage RF channel scanning and tuning. The roVideoPlayer method also has channel scanning capabilities. Object Creation: roChannelManager is created with no parameters. CreateObject("roChannelManager") Interfaces: ifUserData, ifMessagePort, ifSetMessagePort, ifChannelManager, The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object The ifMessagePort interface provides the following: • SetPort(a As Object) The ifSetMessagePort interface provides the following: • SetPort(a As Object) The ifChannelManager interface provides both a Synchronous and Asynchronous API: Synchronous API • Scan(parameters As roAssociativeArray) As Boolean: Performs a channel scan on the RF input for both ATSC and QAM frequencies and builds a channel map based on what it finds. The roChannelManager object stores a list of all channels that are obtained using the CreateChannelDescriptor() method (described below). The list is cleared on each call to Scan() by default, but this behavior can be overridden. 218 Each channel takes approximately one second to scan; you can limit the scope of the channel scan with the following parameters: o ["ChannelMap"] = "ATSC" or "QAM": Limits the frequency scan to either QAM or ATSC. o ["ModulationType"] = "QAM64" or "QAM256": Limits the modulation type of the scan to QAM64 or QAM256. o ["FirstRfChannel"] = Integer and/or ["LastRfChannel"] = Integer: Limits the scan to the • • specified range of channels. The high end of the channel range is an optional parameter. o ["ChannelStore"] = "DISCARD ALL" or "MERGE": Controls how the script handles previous channel scan information. The default setting is DISCARD ALL, which clears all channel data prior to scanning. On the other hand, MERGE overwrites the data only for channels specified in the scan. GetChannelCount() As Integer: Returns the number of found channels. ClearChannelData() As Boolean: Clears all stored channel scanning data, including that which persists in the registry. This method also cancels any AsyncScan() calls that are currently running. • • GetCurrentSnr() As Integer: Returns the SNR (in centibels) of the currently tuned channel. ExporttoXML() As String: Serializes the contents of RF channels into XML. You can write the XML to a file that can be used at a later point on the same or other units. See below for an example of XML output. • ImportFromXML(a As String) As Boolean: Retrieves the RF channel contents stored as XML. The formatting of the XML is controlled using version tags. Example • EnableScanDebug(filename As String) As Boolean: Allows all scan debugging to be written to a text file. By default, there is no debug output from a scan. You can close the debug file by passing an empty string. Example c=CreateObject("roChannelManager") c.EnableScanDebug("tmp:/scandebug.txt") v = CreateObject("roVideoPlayer") aa = CreateObject("roAssociativeArray") aa["RfChannel"] = 12 aa["VirtualChannel"] = "24.1" print v.PlayFile(aa) 220 c.EnableScanDebug("") • CreateChannelDescriptor(a As Object) As Object: Creates an associative array that can either be passed to the roVideoPlayer.PlayFile method (to tune to a channel) or parsed for metadata. The generated channel object can be based on one of the following: o Index: ["ChannelIndex"] = 0 o Virtual channel number as a string in an associative array: ["VirtualChannel"] = "12.1" o Channel name as a string: ["ChannelName"] = "KCBS" Note: Channels are sorted internally by virtual channel, so you could use a ChannelIndex script to implement standard channel up/down behavior. These are the entries generated in the array: o VirtualChannel o ChannelName o CentreFrequency o ModulationType o VideoPid o VideoCodec o AudioPid 221 o o o o o AudioCodec SpectralInversion ChannelMap FirstRfChannel LastRfChannel The last three entries in this array allow you to use the same roArray as a parameter for Scan() and PlayFile(). The first and last RF channel values are set to the same value so that only one RF channel will be scanned. This kind of scan can be performed at the same time as playing the channel because it doesn’t require retuning. Example c=CreateObject("roChannelManager") aa=CreateObject("roAssociativeArray") aa["ChannelMap"] = "QAM" aa["FirstRfChannel"] = 10 aa["LastRfChannel"] = 15 c.Scan(aa) cinfo = CreateObject("roAssociativeArray") cinfo["ChannelIndex"] = 0 desc = c.CreateChannelDescriptor(cinfo) print desc v = CreateObject("roVideoPlayer") v.PlayFile(desc) c.Scan(desc) 222 Asynchronous API • AsyncScan(parameters As roAssociativeArray) As Boolean: Begins a channel scan on the RF input and returns the results immediately. Otherwise, the behavior and parameters of this method are identical to Scan(). When completed or cancelled, AsyncScan() generates an roChannelManagerEvent, which supports ifUserData and outputs two types of event: o 0 – Scan Complete: Generated upon the completion of a scan. No extra data is supplied. o 1 – Scan Progress: Generated upon every tune that is performed during the scan. GetData() returns the percentage complete of the scan. • CancelScan() As Boolean: Cancels any asynchronous scans that are currently running. This method does not generate an roChannelManagerEvent. Synchronous Example c = CreateObject("roChannelManager") ' Scan the channels aa = CreateObject("roAssociativeArray") aa["ChannelMap"] = "ATSC" aa["FirstRfChannel"] = 12 aa["LastRfChannel"] = 50 c.Scan(aa) ' Start at the first channel index = 0 cinfo = CreateObject("roAssociativeArray") cinfo["ChannelIndex"] = index desc = c.CreateChannelDescriptor(cinfo) 223 ' Play the first channel v = CreateObject("roVideoPlayer") v.PlayFile(desc) ' Play the second channel index = index + 1 cinfo["ChannelIndex"] = index desc = c.CreateChannelDescriptor(cinfo) v.PlayFile(desc) Asynchronous Example c = CreateObject("roChannelManager") p = CreateObject("roMessagePort") c.SetPort(p) ' Scan the channels aa = CreateObject("roAssociativeArray") aa["ChannelMap"] = "ATSC" aa["FirstRfChannel"] = 12 aa["LastRfChannel"] = 50 c.AsyncScan(aa) loop: msg = Wait(2000,p) if msg = 0 then goto scan_complete 224 goto loop scan_complete: ' Start at the first channel index = 0 cinfo = CreateObject("roAssociativeArray") cinfo["ChannelIndex"] = index desc = c.CreateChannelDescriptor(cinfo) ' Play the first channel v = CreateObject("roVideoPlayer") v.PlayFile(desc) ' Rescan the current channel, and update the desc["ChannelStore"] = MERGE c.Scan(desc) 225 roControlPort This object is an improved version of roGpioControlPort. It provides support for the IO port of the BP200 and BP900 USB botton boards as well as the on-board I/O port and side buttons on the BrightSign player. It also supports button-up events. The object is used to configure output levels on the I/O connector and monitor inputs. Typically, LEDs and buttons are attached to the I/O connector on the BrightSign player or the BrightSign Expansion Module. Object creation: CreateObject("roControlPort", name as String) For name, use one of the following: • BrightSign to specify the onboard DA-15 connector (on HD210, HD410, HD1010w, HD1020, XD1030, and XD1230) and side buttons (i.e. SVC button and reset button). • Expander-GPIO to specify the DB-25 connector on the BrightSign Expansion Module. If no BrightSign Expansion module is attached, then object creation will fail and Invalid will be returned. • Expander-DIP to specify the eight DIP switches on the BrightSign Expansion Module. If no BrightSign Expansion module is attached, then object creation will fail and Invalid will be returned. Note: Hot-plugging the BrightSign Expansion Module is not supported. Interfaces: ifControlPort, ifSetMessagePort The ifControlPort interface provides the following: • GetVersion() as String: Returns the version number of the firmware (either the main BrightSign firmware or the BrightSign Expansion Module firmware) responsible for the control port. 226 • EnableOutput(pin as Integer) as Boolean: Marks the specified pin as an output. If an Invalid pin number is passed, False will be returned. If successful, the function returns True. The pin will be driven high or low depending on the current output state of the pin. • EnableInput(pin as Integer) as Boolean: Marks the specified pin as an input. If an Invalid pin number is passed, False will be returned. If successful, the function returns True. The pin will be tri-stated and can be driven high or low externally. • GetWholeState as Integer: Returns the state of all the inputs attached to the control port as bits in an integer. The individual pins can be checked using binary operations, although it is normally easier to call IsInputActive instead. • IsInputActive(pin as Integer) as Boolean: Returns the state of the specified input pin. If the pin is not configured as an input, then the result is undefined. • SetWholeState(state as Integer): Specifies the desired state of all outputs attached to the control port as bits in an integer. The individual pins can be set using binary operations, although it is normally easier to call SetOutputState instead. • SetOutputState(pin as Integer, level as Boolean): Specifies the desired state of the specified output pin. If the pin is not configured as an output, the resulting level is undefined. • GetIdentity() as Integer: Returns the identity value that can be used to associate roControlUp and roControlDown events with this control port. The ifSetMessagePort interface provides the following: • SetPort(port as Object): Requests that all events raised on this control port be posted to the specified message port. 227 roControlUp, roControlDown These objects are posted by the control port to the configured message port when inputs change state. The roControlUp and roControlDown objects are not normally created directly. An roControlDown event is posted when the input level goes from high to low. An roControlUp event is posted when the input level goes from low to high. Interfaces: ifInt, ifSourceIdentity The ifInt interface provides the following: • GetInt() as Integer: Retrieves the pin number associated with the event. The ifSourceIdentity interface provides the following: • GetSourceIdentity() as Integer: Retrieves the identity value that can be used to associate events with the source roControlPort instance. 228 roGpioControlPort, roGpioButton Note: New scripts should use roControlPort instead of roGpioControlPort. roGpioControlPort This object is used to control and wait for events on the BrightSign generic DB15 control port. Typically, LEDs or buttons are connected to the DB15 / DB25 port. Turning on a GPIO output changes the voltage on the GPIO port to 3.3V. Turning off a GPIO output changes the voltage on the GPIO port to 0V. The GPIO ports are bidirectional and must be programmed as either inputs or outputs. The IDs range from 0–7. The SetWholeState() method will overwrite any prior output settings. The SetOutputState() takes an output ID (1, 2, or 6, for example). The SetWholeState() method takes a mask (for example, SetWholeState(2^1 + 2^2 ) will set IDs 1 and 2). Interfaces: ifSetMessagePort, ifGpioControlPort The ifSetMessagePort interface provides the following: • SetPort(obj As Object) As Void The ifGpioControlPort interface provides the following: • • • • • • IsInputActive(input_id As Integer) As Boolean GetWholeState() As Integer SetOutputState(output_id As Integer, onState As Boolean) As Void SetWholeState(on_state As Integer) As Void EnableInput(input_id As Integer) As Boolean EnableOutput(output_id As Integer) As Boolean 229 roGpioButton Interfaces: ifInt, ifIntOps The ifInt interface contains the input ID listed above and provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifIntOps interface provide the following: • ToStr() As String 230 roIRRemote This component supports receiving and transmitting arbitrary Infrared remote control codes using the NEC and PHC (Pronto Hex Code) protocols. The best way to determine the required send values is to capture the codes received by roIRRemote when the remote buttons of the device are pressed and then send the same codes. NEC codes are expressed in 24 bits: • Bits 0-7: Button code • Bits 8-23: Manufacturer code Note: If the manufacturer code is zero, then the code is considered to be intended for the Roku SoundBridge remote control. Interfaces: ifSetMessagePort, ifIRRemote. The ifSetMessagePort interface provides the following: • SetPort(message_port_object As Object) As Void The ifIRRemote interface provides the following: • Send(protocol as String, code as Integer) As Boolean: Sends the specified code using the IR blaster. The system currently supports two IR transmission protocols: "NEC" and "PHC" (Pronto Hex Code). This method returns True if the code was successfully transmitted, but there is no way to determine from BrightScript if the controlled device actually received it. Raw captures of Pronto Hex commands will likely not work with the inbuilt IR blaster on XD players, though they should work with Iguanaworks IR transceivers. This is a result of the trailing off periods, which are too long to be ecoded properly. Changing the off periods to all zeros ("0000") will fix this issue. 231 Example: The following example sends an "ON" command to a Panasonic television using a single string of Pronto Hex Code. You can also provide Pronto Hex Code as an roArray of hex values, which results in less work for the script engine. ir = CreateObject("roIRRemote") pronto_hex_Panasonic_on_str = " 0000 0071 0000 0032 0080 003F 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0010 0010 0010 0010 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0010 0010 0030 0010 0000" ir.Send("PHC", pronto_hex_lg_on_str) 232 roIRRemotePress Messages are generated upon key presses from the Roku Soundbridge remote. Interfaces: ifInt, ifIntOps The ifInt interface contains keycode and provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifIntOps interface provides the following: • ToStr() As String For the Roku SoundBridge remote control, the Integer returned can have one of the following values: West 0 East 1 North 2 South 3 Select 4 Exit 5 Power 6 Menu 7 Search 8 Play 9 Next Previous Pause 10 11 12 233 Add Shuffle Repeat Volume up Volume down Brightness 13 14 15 16 17 18 234 roKeyboard, roKeyboardPress roKeyboard This object is used to wait for events from a USB keyboard. Interfaces: ifSetMessagePort The ifSetMessagePort interface provides the following: • SetPort(As Object) As Void roKeyboardPress This object is a keyboard event resulting from the user pressing a key on a USB keyboard. The int value is equivalent to the ASCII code of the key that was pressed. Interfaces: ifInt, ifIntOps The ifInt interface contains the ASCII value of key presses and provides the following: • • GetInt() As Integer SetInt(a As Integer) The ifIntOps interface provides the following: • ToStr() As String 235 The rotINT32 returned can have one of the following values: Letter Keys Number Keys Function Keys Misc Keys Special Keys A - 97 R - 114 0 - 48 F1 - 32826 Del - 127 "-" 45 : 58 B - 98 S - 115 1 - 49 F2 - 32827 Backspace - 8 "=" 61 " 34 C - 99 T - 116 2 - 50 F3 - 32828 Tab - 9 \ 92 < 60 D - 100 U - 117 3 - 51 F4 - 32829 Enter - 13 ` 96 > 62 E - 101 V - 118 4 - 52 F5 - 32830 Print Scrn - 32838 [ 91 ? 63 F - 102 W - 119 5 - 53 F6 - 32831 Scrl Lock - 32839 ] 93 ! 33 G - 103 X - 120 6 - 54 F7 - 32832 Pause/Brk - 32840 ; 59 @ 64 H - 104 Y - 121 7 - 55 F8 - 32833 INS - 32841 " ' " 39 # 35 I - 105 Z - 122 8 - 56 F9 - 32834 Home - 32842 , 44 $ 36 9 - 57 F11 - 32836 Page Up - 32843 . 46 % 37 F12 - 32837 Page Down - 32846 / 47 ^ 94 L - 108 End - 32845 _ 95 & 38 M - 109 Caps - 32811 "+" 43 * 42 N - 110 Left Arrow - 32848 O - 111 J - 106 K - 107 | 124 ( 40 Right Arrow - 32847 ~ 126 ) 41 P - 112 Up Arrow - 32850 { 123 Q - 113 Down Arrow - 32849 } 125 236 roMessagePort A message port is the destination where messages (events) are sent. See the Event Loops section for more details. You do not call these functions directly when using BrightScript. Instead, use the "Wait" BrightScript statement (see the BrightScript Reference Guide for more details). Interfaces: ifMessagePort, ifEnum The ifMessagePort interface provides the following: • • • • • GetMessage() As Object WaitMessage(timeout As Integer) As Object PostMessage(msg As Object) As Void PeekMessage() As Object SetWatchdogTimeout(seconds As Integer) As Integer: Enables a watchdog timeout on the roMessagePort instance. The watchdog on roMessagePort is disabled by default. Passing a positive integer to this method instructs the watchdog to crash and reboot the player if GetMessage() or WaitMessage() does not return after the specified number of seconds. Passing zero to this method disables the watchdog again. Note: The watchdog timeout will not trigger while waiting on the BrightScript debugger prompt. • DeferWatchdog(a As Integer): Defers the watchdog timeout set by the SetWatchdogTimeout() method. Passing an integer to this method defers the timeout for the specified number of seconds. DeferWatchdog(): Defers the watchdog timeout by the amount of seconds set in the SetWatchdogTimeout() method. Note: Calls to either DeferWatchdog() method cannot cause the watchdog to trigger earlier than it already will. For example, calling DeferWatchdog(100) followed by DeferWatchdog(10) will still cause the watchdog to trigger • after 100 seconds. 237 The ifEnum interface provides the following: • • • • Reset(): Resets the position to the first element of enumeration. Next() As Dynamic: Returns the typed value at the current position and increment position. IsNext() As Boolean: Returns True if there is a next element. IsEmpty() As Boolean: Returns True if there is not a next element. 238 roSequenceMatcher This object is used to send roSequenceMatchEvent events when the specified byte sequence patterns are matched. Once a pattern has been matched and the event has been posted, all contributing bytes are discarded. As a result, if one pattern is a prefix of another pattern, then the second, longer pattern will never be matched by the object. Interfaces: ifStreamReceiveObserver, ifSequenceMatcher The ifSequenceMatcher interface provides the following: • SetMessagePort(a As Object): Specifies the message port where roSequenceMatchEvent objects will be posted. • Add(pattern As Object, user_data As Object) As Boolean: Adds a pattern to be matched by the roSequenceMatcher object instance. The pattern should be specified as an object that is convertible to a byte sequence (e.g. roByteArray, roString). For the user data, pass the object that should be returned if the specified pattern is matched. Example Function FromHex(hex as String) as Object bytes = CreateObject("roByteArray") bytes.FromHexString(hex) return bytes End Function Sub Main() serial = CreateObject("roSerialPort", 1, 115200) mp = CreateObject("roMessagePort") 239 button1_seq = FromHex("080a01040001e000") button2_seq = FromHex("080e01040001e000") matcher = CreateObject("roSequenceMatcher") matcher.SetMessagePort(mp) matcher.Add(button1_seq, { name: "button1" }) matcher.Add(button2_seq, { name: "button2" }) matcher.Add("flibbet", { name: "flibbet" }) matcher.Add("flobbet", { name: "flobbet" }) if not serial.SetMatcher(matcher) then stop end if finished = false while not finished ev = mp.WaitMessage(10000) if ev = invalid then finished = true else if type(ev) = "roSequenceMatchEvent" then print "Got button: "; ev.GetUserData().name else print "Unexpected event: "; type(ev) end if end while End Sub 240 241 roSequenceMatchEvent This object is generated whenever roSequenceMatcher matches a specified byte sequence pattern. Interfaces: ifUserData The ifUserData interface provides the following: • • SetUserData(user_data As Object): Sets the user data that will be returned when events are raised. GetUserData() As Object: Returns the user data that has previously been set via roSequenceMatcher.Add() roSequenceMatchEvent.SetUserData(). It will return Invalid if no data has been set. 242 roSerialPort This object controls the RS232 serial port, allowing you to receive input and send responses. roSerialPort sends the following event types: • roStreamLineEvent: The line event is generated whenever the end of line string set using SetEol is found and contains a String for the whole line. This object implements the ifString and ifUserData interfaces. • roStreamByteEvent: The byte event is generated on every byte received. This object implements the ifInt and ifUserData interfaces. Interfaces: ifStreamSend, ifStreamReceive, ifSerialControl, ifUserData The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • Flush() The ifStreamReceive interface provides the following: • • • • SetLineEventPort(port As Object) As Void SetByteEventPort(port As Object) As Void SetReceiveEol(a As String) SetMatcher(matcher As Object) As Boolean: Instructs the stream to use the specified matcher. This object returns True if successful. Pass Invalid to this method to stop using the specified matcher. 243 The ifSerialControl interface provides the following: • SetBaudRate(baud_rate As Integer) As Boolean: Sets the baud rate of the device. The supported baud rates are as follows: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400. • SetMode(mode As String) As Boolean: Sets the serial mode in "8N1" syntax. The first character is the number of data bits. It can be either 5, 6, 7, or 8. The second number is the parity. It can be "N"one, "O"dd, or "E"ven. The third is the number of stop bits. It can be 1 or 2. • SetEcho(enable As Boolean) As Boolean: Enables or disables serial echo. It returns True on success and False on failure. • • SetEol(a As String) SetInverted(inverted As Boolean) As Boolean: Inverts the signals on the player serial port. This allows the player to communicate with most PCs that use -12v to 12v signaling. Passing True to the method enables inversion, whereas passing False disables it. • SendBreak(duration_in_ms As Integer) as Boolean: Sends a serial break or sets the serial break condition. This method returns True upon success and False upon failure. a. duration_in_ms = -1: Sends a continuous break. b. duration_in_ms = 0: Clears the break state. c. duration_in_ms >= 100: Sets the break condition for the specified period of milliseconds (note that this integer is only accurate to the tenth of a second). The ifUserData interface provides the following: • • SetUserData(user_data As Object): Sets the user data that will be returned when events are raised. GetUserData() As Object: Returns the user data that has previously been set via SetUserData. It will return Invalid if no data has been set. Example: This code waits for a serial event and echoes the input received on the serial port to the shell. 244 serial = CreateObject("roSerialPort", 0, 9600) p = CreateObject("roMessagePort") serial.SetLineEventPort(p) serial_only: msg = Wait(0,p) ' Wait forever for a message. if(type(msg) <> "roStreamLineEvent") goto serial_only 'Accept serial messages only. serial.SendLine(msg) ' Echo the message back to serial. 245 SYSTEM OBJECTS roDeviceInfo This object provides information about the device hardware, firmware, and features. Interfaces: ifDeviceInfo The ifDeviceInfo interface provides the following: • GetModel() As String: Returns the model name for the BrightSign device running the script as a string (for example, "HD1020" or "XD230"). • GetVersion() As String: Returns the version number of the BrightSign firmware running on the device (for example, "4.0.13"). • GetVersionNumber() As Integer: Returns the version number of the BrightSign firmware running on the device in the more comparable numeric form of (major*65536 + minor*256 + build). • GetBootVersion() As String: Returns the version number of the BrightSign boot firmware, also known as "safe mode", as a string (for example, "1.0.4"). • GetBootVersionNumber() As Integer: Returns the version number of the BrightSign boot firmware, also known as "safe mode," in the more comparable numeric form of (major*65536 + minor*256 + build). • GetDeviceUptime() As Integer: Returns the number of seconds that the device has been running since the last power cycle or reboot. • GetDeviceUniqueId() As String: Returns an identifier that, if not an empty string, is unique to the unit running the script. • GetFamily() As String: Returns a single string that indicates the family to which the device belongs. A device family is a set of models that are all capable of running the same firmware. • GetDeviceLifetime() As Integer 246 • HasFeature(feature As String) As Boolean: Returns True if the player feature, which is passed as a case-insensitive string parameter, is present on the current device and firmware. These are the possible features that can be queried from the script: Note: If you pass a parameter other than one of those listed below, it may return False even if the feature is available on the hardware and firmware. o "brightscript1": BrightScript Version 1 o "brightscript2": BrightScript Version 2 o "networking": Any form of networking capability; there may be no network currently available. o "hdmi" o "component video" o "vga" o o o o o o o o o o o o o "audio1": The first audio output "audio2": A second audio output "audio3": A third audio output "ethernet" "usb" "rs232" "5v serial" "gpio connector" "gpio12 button" "reset button" "rtc" "registry" "nand storage" o "sd": SD or SDHC o "sdhc": SDHC only 247 Example: di = CreateObject("roDeviceInfo") print di.GetModel() print di.GetVersion(), di.GetVersionNumber() print di.GetBootVersion(), di.GetBootVersionNumber() print di.GetDeviceUptime(), di.GetDeviceBootCount() On a particular system, this generates: HD1010 3.2.41 3.2.28 14353 197161 197148 3129 248 roResourceManager The roResourceManager is used for managing strings in multiple languages. Object creation: CreateObject("roResourceManager", filename As String): filename is 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. Interfaces: ifResourceManager The interface ifResourceManager provides the following: • SetLanguage(language_identifier As String) As Boolean: Instructs the roResourceManager object to use the specified language. False is returned if there are no resources associated with the specified language. • GetResource(resource_identifier As String) As String: Returns the resource string in the current language for a given resource identifier. • • GetFailureReason() As String: Yields additional useful information if a function return indicates an error. GetLanguage() As String At present, roResourceManager is primarily used for localizing the roClockWidget. The resource file passed in during creation has the following format for each string entry: [RESOURCE_IDENTIFIER_NAME_GOES_HERE] eng "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec" ger "Jan|Feb|Mär|Apr|Mai|Jun|Jul|Aug|Sep|Okt|Nov|Dez" spa "Ene|Feb|Mar|Abr|May|Jun|Jul|Ago|Sep|Oct|Nov|Dic" fre "Jan|Fév|Mar|Avr|Mai|Jun|Jul|Aou|Sep|Oct|Nov|Déc" 249 ita "Gen|Feb|Mar|Apr|Mag|Giu|Lug|Ago|Set|Ott|Nov|Dic" dut "Jan|Feb|Mar|Apr|Mei|Jun|Jul|Aug|Sep|Okt|Nov|Dec" swe "Jan|Feb|Mar|Apr|Maj|Jun|Jul|Aug|Sep|Okt|Nov|Dec" The name in square brackets is the resource identifier. Each line after it is a language identifier followed by the resource string. Multiple roResourceManager objects can be created. A default "resources.txt" file, which contains a range of internationalization for the clock widget, is available from the BrightSign website. 250 roSystemLog This object enables the application to receive events that are intended for reporting errors and trends, rather than for triggering a response to a user action. roSystemLog requires specific design patterns in your BrightScript application: • • • • Use one roMessagePort throughout the application (instead of creating a new roMessagePort for each screen). Create one roSystemLog instance at startup that remains for the entire lifetime of the application. Pass the global roMessagePort mentioned above to SetMessagePort() on the roSystemLog component. Enable the desired log types using EnableType(). This object is created with no parameters: CreateObject("roSystemLog") Interfaces: ifStreamSend, ifSystemLog The ifStreamSend interface provides the following: • • • SetSendEol(eol_sequence As String) As Void: Sets the EOL sequence when writing to the stream. SendByte(byte As Integer) As Void: Writes the specified byte to the stream. SendLine(string As String) As Void: Writes the specified characters to the stream followed by the current EOL sequence. • SendBlock(a As Dynamic) As Void: Writes the specified characters to the stream. This method can support either a string or an roByteArray. If the block is a string, any null bytes will terminate the block. • Flush() 251 The ifSystemLog interface provides the following: • ReadLog() As Object 252 DATE AND TIME OBJECTS roDateTime roDateTime represents an instant in time. See roSystemTime and roTimer for other objects with timing functionality. Interfaces: ifDateTime, ifString The ifDateTime interface provides the following: • • • • • • • • • • • • • • • • • GetDayOfWeek() As Integer GetDay() As Integer GetMonth() As Integer GetYear() As Integer GetHour() As Integer GetMinute() As Integer GetSecond() As Integer GetMillisecond() As Integer SetDay(day As Integer) As Void SetMonth(month As Integer) As Void SetYear(year As Integer) As Void SetHour(hour As Integer) As Void SetMinute(minute As Integer) As Void SetSecond(second As Integer) As Void SetMillisecond(millisecond As Integer) As Void AddSeconds(seconds As Integer) As Void SubtractSeconds(seconds As Integer) As Void 253 • • • AddMilliseconds(milliseconds As Integer) As Void SubtractMilliseconds(milliseconds As Integer) As Void Normalize() As Boolean: Checks that all the fields supplied are correct. This function fails if the values are out of bounds. • ToIsoString() As String: Returns the current roDateTime value as an ISO-8601 basic formatted string. Hyphens for date and colons for time are omitted, and a comma is used to separate seconds from milliseconds: For example, the ISO-8601 standard "2014-05-29T12:30:00.100" would be formatted as "20140529T123000,100". • FromIsoString(date-time As String) As Boolean: Sets the value of the roDateTime object using an ISO-8601 basic formatted string. Hyphens for date and colons for time are omitted, and either a period or comma can be used to separate seconds from milliseconds: The ISO-8601 standard "2014-05-29T12:30:00.100" could, for example, be formatted as either "20140529T123000,100" or "20140529T123000.100". This method will return False (indicating that it has not affected changes to the roDateTime object) if the string is formatted incorrectly or if the date passed is outside the range of January 1, 1970 and December 31, 2100. • ToSecondsSinceEpoch() As Integer: Returns the number of seconds that have elapsed since midnight on January 1, 1970, as represented by the roDateTime instance (not the system time). • FromSecondsSinceEpoch(seconds As Integer) As Boolean: Populates the roDateTime instance with the specified number of seconds since midnight on January 1, 1970. • GetString() As String The ifString interface provides the following: • GetString() As String A new object is, at the time of its creation, represented by zero seconds. When used via the ifString interface, ifDateTime will always use the sortable date format "YYYY-MM-DD hh:mm:ss". 254 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. See roDateTime and roTimer for other objects with timing functionality. Interfaces: ifSystemTime. The ifSystemTime interface provides the following: • • • • • • • • GetLocalDateTime() As Object GetUtcDateTime() As Object GetZoneDateTime(timezone_name As String) As Object SetLocalDateTime(localDateTime As roDateTime) As Boolean SetUtcDateTime(utcDateTime As roDateTime) As Boolean GetTimeZone() As String SetTimeZone(zone_name As String) As Boolean IsValid() As Boolean: Returns True if the system time is set to something valid. It can be set from the RTC or NTP. Dates up to 1 January, 2038 are supported. The following are the supported time zones: • • • • • • EST: US Eastern Time CST: US Central Time MST: US Mountain Time PST: US Pacific Time AKST: Alaska Time HST: Hawaii-Aleutian Time with no Daylight Savings (Hawaii) 255 • • • • • • • • • • • • • • • • • • • • • • • • • • • HST1: Hawaii-Aleutian Time with Daylight Saving MST1: US MT without Daylight Saving Time (Arizona) EST1: US ET without Daylight Saving Time (East Indiana) AST: Atlantic Time CST2: Mexico (Mexico City) MST2: Mexico (Chihuahua) PST2: Mexico (Tijuana) BRT: Brazil Time (Sao Paulo) NST: Newfoundland Time AZOT: Azores Time GMTBST: London/Dublin Time WET: Western European Time CET: Central European Time EET: Eastern European Time MSK: Moscow Time SAMT: Delta Time Zone (Samara) YEKT: Echo Time Zone (Yekaterinburg) IST: Indian Standard Time NPT: Nepal Time OMST: Foxtrot Time Zone (Omsk) JST: Japanese Standard Time CXT: Christmas Island Time (Australia) AWST: Australian Western Time AWST1: Australian Western Time without Daylight Saving Time ACST: Australian Central Standard Time (CST) with Daylight Saving Time ACST1: Darwin, Australia/Darwin, and Australian Central Standard Time (CST) without Daylight Saving Time AEST: Australian Eastern Time with Daylight Saving Time 256 • • • • • • • • • • • • • • • • • • • • • • • • • • • AEST1: Australian Eastern Time without Daylight Saving Time (Brisbane) NFT: Norfolk (Island) Time (Australia) 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 behind Greenwich Mean Time GMT-2: 2 hours behind Greenwich Mean Time GMT-3: 3 hours behind Greenwich Mean Time GMT-3:30: 3.5 hours behind Greenwich Mean Time GMT-4: 4 hours behind Greenwich Mean Time GMT-4:30: 4.5 hours behind Greenwich Mean Time GMT-5: 5 hours behind Greenwich Mean Time GMT-6: 6 hours behind Greenwich Mean Time GMT-7: 7 hours behind Greenwich Mean Time GMT-8: 8 hours behind Greenwich Mean Time GMT-9: 9 hours behind Greenwich Mean Time GMT-9:30: 9.5 hours behind Greenwich Mean Time GMT-10: 10 hours behind Greenwich Mean Time GMT-11: 11 hours behind Greenwich Mean Time GMT-12: 12 hours behind Greenwich Mean Time GMT-13: 13 hours behind Greenwich Mean Time GMT-14: 14 hours behind 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+3:30: 3.5 hours ahead of Greenwich Mean Time 257 • • • • • • • • • • • • • • • • • • • • GMT+4: 4 hours ahead of Greenwich Mean Time GMT+4:30: 4.5 hours ahead of Greenwich Mean Time GMT+5: 5 hours ahead of Greenwich Mean Time GMT+5:30: 5.5 hours ahead of Greenwich Mean Time GMT+6: 6 hours ahead of Greenwich Mean Time GMT+6:30: 6.5 hours ahead of Greenwich Mean Time GMT+7: 7 hours ahead of Greenwich Mean Time GMT+7:30: 7.5 hours ahead of Greenwich Mean Time GMT+8: 8 hours ahead of Greenwich Mean Time GMT+8:30: 8.5 hours ahead of Greenwich Mean Time GMT+9: 9 hours ahead of Greenwich Mean Time GMT+9:30: 9.5 hours ahead of Greenwich Mean Time GMT+10: 10 hours ahead of Greenwich Mean Time GMT+10:30: 10.5 hours ahead of Greenwich Mean Time GMT+11: 11 hours ahead of Greenwich Mean Time GMT+11:30: 11.5 hours ahead of Greenwich Mean Time GMT+12: 12 hours ahead of Greenwich Mean Time GMT+12:30: 12.5 hours ahead of Greenwich Mean Time GMT+13: 13 hours ahead of Greenwich Mean Time GMT+14: 14 hours ahead of Greenwich Mean Time 258 roTimer See roDateTime and roSystemTime for other objects with timing functionality. Interfaces: ifTimer, ifIdentity, ifSetMessagePort The ifTimer interface provides the following: • SetTime(hour As Integer, minute As Integer, second As Integer, millisecond As Integer) As Void • • • • • • • SetDate(year As Integer, month As Integer, day As Integer) As Void SetDayOfWeek(day_of_week As Integer) As Void: Sets the time when you wish the event to trigger. In general, if a value is -1, then it is a wildcard and will cause the event to trigger every time the rest of the specification matches. If there are no wildcards, then the timer will trigger only once when the specified date/time occurs. It is possible, using a combination of day and day_of_week, to specify invalid combinations that will never occur. If specifications include any wildcard, then the second and millisecond specifications must be zero. Events will be raised at most once per minute near the whole minute. SetDateTime(As ifDateTime) As Void: Sets the time when you wish the event to trigger from an roDateTime object. It is not possible to set wildcards using this method. Start() As Boolean: Starts the timer based on the current values specified using the above functions. Stop(): Stops the timer. SetTime(a As Integer, b As Integer, c As Integer) SetElapsed(seconds As Integer, milliseconds As Integer): Configures a timer to trigger once the specified time period has elapsed. Unlike the absolute timer methods above, changes to the system clock will not affect the period of the SetElapsed() timer. The ifIdentity interface provides the following: • GetIdentity() As Integer 259 • SetIdentity(a As Integer) The ifSetSetMessagePort interface provides the following: • SetPort(a As Object) Example: This code uses SetElapsed() to create a timer that triggers every 30 seconds. Sub Main() mp = CreateObject("roMessagePort") timer = CreateObject("roTimer") timer.SetPort(mp) timer.SetElapsed(30, 0) print "Start at "; Uptime(0) timer.Start() while true ev = mp.WaitMessage(0) if type(ev) = "roTimerEvent" then print "Timer event received at "; Uptime(0) timer.Start() else print "Another event arrived: "; type(ev) end if end while End Sub 260 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" else print "unexpected event received" endif endwhile Example: This code creates a timer that triggers once at a specific date/time. timer=CreateObject("roTimer") mp=CreateObject("roMessagePort") timer.SetPort(mp) timer.SetDate(2008, 11, 1) 261 timer.SetTime(0, 0, 0, 0) timer.Start() while true ev = Wait(0, mp) if (type(ev) = "roTimerEvent") then print "timer event received" else print "unexpected event received" endif endwhile 262 roTimerEvent Interfaces: ifSourceIdentity The ifSourceIdentity interface provides the following. • • GetSourceIdentity() As Integer SetSourceIdentity(a As Integer) 263 roTimeSpan This object provides an interface to a simple timer for tracking the duration of activities. It is useful for tracking how long an action has taken or whether a specified time has elapsed from a starting event. Interfaces: ifTimeSpan The ifTimeSpan interface provides the following: • • • • Mark() TotalMilliseconds() As Integer TotalSeconds() As Integer GetSecondsToISO8601Date(a As String) As Integer 264 LEGACY OBJECTS roSyncPool We recommend using roAssetPool instead. Object Creation: CreateObject("roSyncPool", pool_path As String) Example: pool = CreateObject ("roSyncPool", "SD:/pool") Interfaces: ifSyncPool, ifIdentity, ifMessagePort, ifUserData The ifSyncPool interface provides the following: • ValidateFiles(sync_spec As roSyncSpec, directory As String, options_array As roAssociativeArray) As Object: Validates the files in the specified directory against the hashes in the specified sync spec. Files that are not in the sync spec are ignored. The options array can currently contain the following optional parameters: o DelteCorrupt (Boolean): Automatically delete files that do not match the sync spec. The method will return an associative array that maps each fileneame to an explanation of why it is corrupt. The array only contains corrupt files, so the success is reported by the method returning an empty associative array. • • GetFailureReason() As String AsyncDownload(a As Object) As Boolean 265 • • • • • • • • • • • • • • • • • • • • • • • • • AsyncCancel() As Boolean Realize(a As Object, b As String) As Object ProtectFiles(a As Object, b As Integer) As Boolean ReserveMegabytes(a As Integer) As Boolean GetPoolSizeInMegabytes() As Integer EstimateRealizedSizeInMegabytes(a As Object, b As String) As Integer IsReady(a As Object) As Boolean Validate(a As Object, b As Object) As Boolean EnablePeerVerification(a As Boolean) EnableHostVerification(a As Boolean) SetCertificatesFile(a As String) SetUserAndPassword(a As String, b As String) As Boolean AddHeader(a As String, b As String) SetHeaders(a As Object) As Boolean SetMinimumTransferRate(a As Integer, b As Integer) As Boolean AsyncSuggestCache(a As Object) As Boolean SetProxy(a As String) As Boolean SetFileProgressIntervalSeconds(a As Integer) As Boolean QueryFiles(a As Object) As Object SetFileRetryCount(a As Integer) As Boolean SetRelativeLinkPrefix(prefix As String) As Boolean BindToInterface(interface As Integer) As Boolean EnableUnsafeAuthentication(a As Boolean) EnableUnsafeProxyAuthentication(enable As Boolean) As Boolean SetMaximumPoolSizeMegabytes(maximum_size As Integer) As Boolean 266 The ifIdentity interface provides the following: • GetIdentity() As Integer The ifMessagePort interface provides the following: • SetPort(a As Object) The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData () As Object 267 roSyncPoolEvent We recommend using roAssetFetcherEvent instead. Interfaces: ifSourceIdentity, ifSyncPoolEvent, ifUserData The ifSourceIdentity interface provides the following: • GetSourceIdentity() As Integer The ifSyncPoolEvent interface provides the following • • • • • GetEvent() As Integer GetName() As String GetResponseCode() As Integer GetFailureReason() As String GetFileIndex() As Integer The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 268 roSyncPoolFiles We recommend using roAssetPoolFiles instead. Interfaces: ifSyncPoolFiles The ifSyncPoolFiles interface provides the following: • • • GetFailureReason() As String GetPoolFilePath(a As String) As String GetPoolFileInfo(a As String) As Object 269 roSyncPoolProgressEvent We recommend using roAssetFetcherProgressEvent instead. Interfaces: ifSourceIdentity, ifSyncPoolProgressEvent, ifUserData The ifSourceIdentity interface provides the following: • GetSourceIdentity() As Integer The ifSyncPoolProgressEvent interface provides the following: • • • • • • GetFileName() As String GetFileIndex() As Integer GetFileCount() As Integer GetCurrentFileTransferredMegabytes() As Integer GetCurrentFileSizeMegabytes() As Integer GetCurrentFilePercentage() As Float The ifUserData interface provides the following: • • SetUserData(a As Object) GetUserData() As Object 270 CHANGE LOG 4.4.x, 4.2.x, 3.10.x March 1, 2013 6.1 Added entries for roDatagramSocket [implemented in version 4.4.47], roXMLElement, roAudioPlayerMx, and roAudioEventMx. 6.2 Added entry for roChannelManager [implemented in version 4.4.51]. 6.3 Added entries for the ifUserData interface [implemented in version 4.4.47] in the roDatagramSender and roDatagramReceiver section. 6.4 Added a description of the SetBackgroundColor() method in the roVideoOutput entry. 6.5 Added a description and listed the possible parameters for HasFeature() in the roDeviceInfo entry. 6.6 Added object creation parameters for roAssetPool and roSyncPool (as well as a more comprehensive introduction for roAssetPool) 6.7 Revised description of the GetResponseCode() method in the roUrlEvent entry. 6.8 Changed the formatting of all example scripts to make them easier to distinguish from definitions and other explanatory language. March 14, 2013 2.1 Added a description of the JoinMulticastGroup()method [implemented in version 4.4.62] to the roDatagramSocket entry. 2.2 Added a description of the EnableScanDebug()method [implemented in version 4.4.62] to the roChannelManager entry. March 27, 2013 3.1 Added descriptions of SetAppCacheDir() and SetAppCacheSize() methods [implemented in version 4.4.71] to the roHtmlWidget entry. 271 3.2 Revised roVideoPlayer entry to include information about new channel scanning functionality. April 8, 2013 4.1 Removed uses of "CF:" (compact flash) and "ATA:" directories from example scripts in favor of "SD:" 4.2 Added description of GetEdidIdentity() [implemented in 4.4.73] to the roVideoMode entry. 4.6.x, 4.4.x, 3.10.x April 29, 2013 1.1 Revised listing and description of Australian time zones in the roSystemTime entry. 1.2 Added description of ifSerialPort.SendBreak() [implemented in 4.6.14] to the roSerialPort entry. June 11, 2013 2.1 Added a description of the GetDiagnosticInfo() method [implemented in version 4.5.11] to the roTouchScreen entry. 2.2 Added a description of the AddGetFromString() method [implemented in version 4.6.14] to the roHttpServer entry. July 11, 2013 3.1 Added descriptions for all instances of ifStreamSend.SendBlock(). 3.2 Added descriptions of EnableUnsafeProxyAuthentication() to the roUrlTransfer and roAssetFetcher entries. 3.3 Added a description of EnableUnsafeAuthentication() to the roAssetFetcher entry. July 17, 2013 4.1 Expanded object creation entry for roAssetCollection. 4.2 Added a description of objection creation parameters for the roAssetPoolFiles, roAssetFetcher and roAssetRealizer entries. 272 July 22, 2013 5.1 Added descriptions of the ProtectAssets() and UnprotectAssets() methods to the roAssetPool entry. 5.2 Added a full description of methods and their parameters to the roAssetPoolFiles entry. 5.3 Added a full description of methods and their parameters to the roAssetRealizer entry. August 16, 2013 6.1 Removed the description of ReadLog() from the entry for roSystemLog. 6.2 Added the following method descriptions to the roUrlTransfer entry: ClearHeaders(), AddHeaders(), PutFromString(), PutFromFile(), AsyncPutFromString(), AsyncPutFromFile(), Delete(), AsyncDelete(). 4.7.x August 8, 2013 1.1 Added entires for the roDiskMonitor and roDiskErrorEvent objects. September 10, 2013 2.1 Added a description for the roGlobal.EjectDrive() method. 2.2 Added descriptions of the roHdmiInputChanged event object, as well as the GetHdmiInputStatus() method, to the roVideoMode entry. October 1, 2013 3.1 Added descriptions for the roAudioPlayer.SetAudioDelay() and roAudioPlayer.SetVideoDelay() methods (this applies to roVideoPlayer as well). Added a description for the related roAudioOutput.SetAudioDelay() method as well. 3.2 Added an entry and comprehensive description for roNetworkStatistics. 3.3 Added an entry for the roMediaStreamer and roMediaStreamerEvent objects. 3.4 Expanded the entry for roIRRemote to include support for the Pronto Hex Code (PHC) protocol. 273 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 Included additional explanation and an example for roStorageHotplug. Added descriptions for the roVideoPlayer.AdjustVideoColor() and roVideoMode.AdjustGraphicsColor() methods. Added descriptions for roVideoMode.GetVideoResX / GetVideoResY and roVideoMode.GetOutputResX / GetOutputResY. Also revised description of roVideoMode.GetResX / GetResY. Updated and corrected the list of supported baud rates for roSerialPort.SetBaudRate() and roTouchScreen.SetBaudRate() methods. Added a description for the roSerialPort.SetInverted method. Added descriptions for the roDateTime.ToSecondsSinceEpoch and roDateTime.FromSecondsSinceEpoch methods. Added a description for the roNetworkConfiguration.SetInboundShaperRate() method. Added an example script to the roNetworkAdvertisement entry. Expanded description for roUrlTransfer.SetTimeout(). Revised the descriptions for the ro*File.Flush() and ro*File.AsyncFlush() methods. Added a description for the roSyncPool.ValidateFiles() method. October 17, 2013 4.1 Revised the description of alpha values in roTextWidget to reflect the fact that they affect both text and canvas color in 4.7. October 25, 2013 5.1 Revised the roMediaStreamer entry to reflect new functionality. 5.2 Added a description of the SetMaximumPoolSizeMegabytes() method to the roAssetPool and roSyncPool 5.3 5.4 5.5 entries. Added the ifUserData interface to the roAssetRealizer object. Added entries for the new SetWatchdogTimout() and DeferWatchdog() methods in the roMessagePort section. Added entry for new roTimer.SetElapsed() method, as well as an example showing how to use roTimer.SetElapsed(). 274 November 18, 2013 6.1 Added descriptions for most roGlobal methods. 6.2 Expanded the description of the roNetworkConfiguration.SetHostName() method. December 12, 2013 7.1 Added a description for the roNetworkConfiguration.SetupDWS() method. January 28, 2014 8.1 Added a description for the roHtmlWidget.SetUserAgent() method. Also added an example of the standard useragent string reported by WebKit. 8.2 Added a list of standard URL syntax iterations that can be used with roNetworkConfiguration. SetTimeServer(). 8.3 Added descriptions for the roSequenceMatcher and roSequenceMatchEvent objects. 8.4 Add a description of the SetMatcher() method to the roTCPStream and roSerialPort objects. February 13, 2014 9.1 Added an entry for the new roTCPConnectEvent.GetSourceAddress() method (implemented in 4.7.144). 9.2 Revised the description for roTCPServer.BindToPort to reflect new functionality (implemented in 4.7.144). 9.3 Added entries and descriptions for the new roSyncManager and roSyncManagerEvent objects. 9.4 Added a description for the UserString parameter that can be passed to roAudioPlayerMx. 9.5 Added a description for the roAudioEventMx object. March 9, 2014 10.1 Added documentation for the roSqliteDatabase, roSqliteEvent, and roSqliteStatement objects. 10.2 Revised the roRssParser script example so that the call to roTextWidget.EnableForegroundColor() includes an alpha value. 10.3 Added more descriptive parameters to several roHtmlWidget methods. 275 March 25, 2014 11.1 Added documentation for the new roVideoMode.Screenshot() method. 11.2 Clarified some of the information in the entry for roImagePlayer. 11.3 Added more descriptive parameter names to several roHtmlWidget methods. April 10, 2014 12.1 Revised the interface listings for roNetworkConfiguration and added the ifMessagePort and ifUserData interfaces. 12.2 Split the roReadFile, roWriteFile, roReadWriteFile, roAppendFile section into different sections for each object, and created a new "File Objects" chapter specifically for these objects. Added object descriptions to object entry. 12.3 Added additional information to the roCecRxFrameEvent and roCecTxCompleteEvent entry (including a description for the objects. 12.4 Modernized some of the information in the roDeviceInfo entry. 12.5 Updated several method entries for roVideoMode. Also added an entry for the SaveEdids() method. May 12, 2014 13.1 Revised example scripts in the roImageWidget entry so that they actually use roImageWidget objects. 13.2 Made the parameters of some roRegex methods more specific. 13.3 Added descriptions for the PreloadFile(), DisplayFile(), and SetTransitionTime() methods in the 13.4 13.5 13.6 roImagePlayer entry. Added entires for the Hide() and Show() methods in the roImagePlayer entry. Added return types and descriptions to ifSendStream methods for roTextField, roSerialPort, roSystemLog, and roTCPStream. Added descriptions for ifWidget methods in the roClockWidget entry. May 29, 2014 14.1 Removed legacy information involving mouse cursor bitmaps from the roTouchScreen entry. Added a more thorough and up-to-date description for the SetCursorBitmap() method. 276 14.2 14.3 14.4 14.5 14.6 Added a deprication notice to the SetTempDirectory() method in the entry for roSqliteDatabase. Added descriptions for most roSyncSpec methods. Added descriptions for the ToIsoString() and FromIsoString() methods in the roDateTime entry. Added the default transition duration to the description of roImagePlayer.SetTransitionDuration(). Changed the supported interface in the roSyncManager entry from ifCecInterface to ifSyncManager. 277 2 42 2197 0 1 1 42 7 0 1 2
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : Yes Tagged PDF : Yes XMP Toolkit : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04 Modify Date : 2014:05:29 14:57:03-07:00 Create Date : 2014:05:29 14:55:07-07:00 Metadata Date : 2014:05:29 14:57:03-07:00 Creator Tool : Acrobat PDFMaker 9.1 for Word Document ID : uuid:e47ba860-96d9-40f8-83a7-354ac9d1df09 Instance ID : uuid:1914bdfe-c8ac-4a11-80fa-e7d7ca39fa39 Format : application/pdf Title : Creator : Producer : Adobe PDF Library 9.0 Page Layout : OneColumn Page Count : 284 Author :EXIF Metadata provided by EXIF.tools