Questions tagged [brightscript]

Brightscript is a BASIC-like language developed for the Roku and Brightsign hardware platforms.

Brightscript is a BASIC-like language developed for the Roku and Brightsign hardware platforms.

Brightscript is single threaded, procedural language with some object oriented features. It lacks support for Classes and Inheritance. Brightscript allows only one global variable, "m". However m can contain a complex global data structure. Arrays are one-dimensional; however, you can create arrays of arrays.

There are two primary types of array variables: roArray and roAssociativeArray.

Arrays can be defined with a CreateObject statement or using shorthand

varname=createobject(roArray,5,true) 

creates an expandable array containing 5 elements. Alternatively:

varname=[]

creates an empty, but expandable Array.

roAssociativeArrays can also be described as a data dictionary. They can be created as follows:

varname=createobject(roAssociativeArray)

or

varname={}

using curly brackets.

To assign values to an Array:

varname=[100,200,"ABCD","ZYXW"]

or

varname[0]=100
varname[1]=200
varname[2]="ABCD"
varname[3]="ZYXW"

to assign values to an AssociativeArray or "AA":

varname={name:"John Smith",address:"1023 West Alameda",telephone:"415-555-1212"}

or

varname={}
varname["name"]="John Smith"
varname["address"]="1023 West Alameda"
varname["telephone"]="415-555-1212"

a mode which allows almost any ASCII character to be used as a key, or, using dot notation:

varname={}
varname.name="John Smith"
varname.address="1023 West Alameda"
varname.telephone="415-637-1283"

Aside from the usual text and numeric manipulation functions, Brightscript also has specialized objects that can be created, such as "roAudioPlayer", "roVideoPlayer" and many different display screen types, the most commonly used are "roPosterScreen" and "roGridScreen". These objects are created and assigned a reference variable in the following manner:

screen=CreateObject("roPosterScreen")

It could then be populated:

item1={ShortDescriptionLine1:"item 1"}
item2={ShortDescriptionLine1:"item 2"}
item3={ShortDescriptionLine1:"item 3"}

content=[item1,item2,item3]   

screen.setcontentlist(content)

Note that item 1 2 and three are roAssociativeArrays and that content is an roArray containing three roAssociativeArrays.

To display the screen:

screen.show()

Instead of a REM statement, Brightscript uses the single quote:

'this is a comment

Program Execution statements include:

  • For / End For / Exit for
  • While / End While / Exit While
  • If / Then / Else / Else If / End If

Brightscript is not Case Sensitive for the most part; however, string comparisons and AssociativeArray keys can be case sensitive.

For more information on Brightscript, please see the following links:

Roku Developer Guide

BrightScript Language Reference

Roku Developer Program signup link

And the frequently helpful Roku Developers Forum

415 questions
2
votes
1 answer

Roku app exits without error on second roMessagePort wait

This is the smallest snippet I've been able to get to reproduce the issue. Sub Main() u = getStringFromKeyboard("Enter username") p = getStringFromKeyboard("Enter password") End Sub Function getStringFromKeyboard(message = "" As String) As…
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
2
votes
1 answer

Images not loaded, When I update a content in PosterGrid

I used Custom SGDex View in MainScene and Using the below code, I have opened the dialog box inside PostGrid. It's Extends With the Group node. sub init() m.postergrid = m.top.findNode("PosterGrid") m.top.GlobleURL = GetAuthData("URL") …
2
votes
1 answer

Roku ParseJSON gives Unknow Identifier error when loading json via AJAX

I'm trying to write a simple Roku application. When I load the JSON file via roURLTransfer ParseJSON function gives me BRIGHTSCRIPT: ERROR: ParseJSON: Unknown identifier. If I load the JSON file via ReadAsciiFile("pkg:/feed/feed.json") it works. The…
Farid Rn
  • 3,167
  • 5
  • 39
  • 66
2
votes
1 answer

Execution time out in task node

I'm getting the issue(Execution TimeOut) with the Task node. I created one Timer in the Scene node for Continuous Execute Function Here I Tried With Continuous Response Update With Task node and After It used in Scene Node. 'Timer m.Update =…
2
votes
0 answers

Read JSON Data From Browser in Roku

I tried to read multiple JSON files from the browser. The same thing uses with XML in the below code. sub getcontent() content = createObject("roSGNode", "ContentNode") contentxml = createObject("roXMLElement") if m.top.contenturi.left(4) =…
2
votes
1 answer

2D Array in Roku

It is possible to create 2D Array. I used m.value = CreateObject("roArray", 0 , true) But It's only create a one dimensional array. Here I create only single Row and multiple Column 0 1 2 3 I tried to create a 2D array in Roku. Here I tried to…
2
votes
1 answer

Is it possible to extend an Interpolator?

I'm trying to extend a Vector2DFieldInterpolator in order to make a smooth arc animation given three points (start, end, and a point inbetween). I've gotten it to work by setting the key and keyValue fields on a regular Vector2DFieldInterpolator,…
MMAdams
  • 1,508
  • 15
  • 29
2
votes
1 answer

Brightscript generated signed URLs for CloudFront yield "Access Denied"

I'm working on a Roku channel, and we want to have files hosted in an AWS S3 bucket, with CloudFront to distribute the content. Before considering security, it worked fine. However, now that I'm trying to be mindful of security issues, I'm…
bmbudai
  • 31
  • 4
2
votes
1 answer

Difference between AsyncGetToString and AsyncPostFromString?

I create one web API. and I call in bright-script. I refer https://developer.roku.com/en-gb/docs/references/brightscript/interfaces/ifurltransfer.md#head-as-dynamic/ all the method but don't understand anyone knows its real use for AsyncGetToString…
2
votes
1 answer

Concept of WebView in Roku

Is there any concept of Webview in Roku like android iOS. I just want open web site through URL. In Roku document not Webview related information available.
DEEPAK MITTAL
  • 141
  • 1
  • 1
  • 10
2
votes
2 answers

How to fetch image in Roku BrightScript?

The below Curl returns an image. I am struggling to find Roku equivalent code to fetch an image and display it in poster node. curl -X GET \ …
Naren
  • 1,504
  • 16
  • 19
2
votes
2 answers

"Should" the roku video node be created in task thread always?

The video node can be created in both render thread & task node thread. Is there a mandate on video node to be created only in "task node" thread? From the definition of render thread, it says that render thread must be used to create UI elements &…
Kedar Nath
  • 23
  • 2
2
votes
1 answer

ROKU: open another Scene/Screen from a screen

With the use of Task inside a Scene, we got response from a api. But how to access the response of Task from main.brs? Can we change the scene from a scene in a scenegraph? I could not figure that. Or can we only change the scene from main.brs?
Ajay Paudel
  • 322
  • 1
  • 12
2
votes
2 answers

Roku : Writing to Registry

When writing values to the registry, does this really have to be done using a task Task ? Snippet from https://sdkdocs.roku.com/display/sdkdoc/BrightScript+Support roRegistry : Can only be used in a Task node roRegistrySection : Can only be…
Fabii
  • 3,820
  • 14
  • 51
  • 92
2
votes
2 answers

Playing Multiple Video Nodes at the same Time - Roku SDK

I am trying to overlay two video screens and play them simultaneously, with the audio on one muted. However, it seems like Roku only supports the playback of one Video at a time. Is there any way to play both Video nodes simultaneously? Any help is…
1 2
3
27 28