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
2 answers

Bring Focus back to the node in roku

Hi I am developing an SDK which shows custom views when user performs some events in the app. I have created xml of those views and had been able to render it via scene. But an issue faced is that when this custom view is shown focus is transferred…
Vaisakh Vinod
  • 267
  • 2
  • 14
2
votes
2 answers

roVideoPlayer is depreciated. Is there any alternate for streaming videos?

In brightscript, roVideoPlayer will have been depreciated from 2019. Is there any alternate for playing streaming videos? I have tried Video as a component but I only see a blank and black screen.
ganka
  • 191
  • 1
  • 11
2
votes
3 answers

How to write global function in brightscript?

I am working for Roku Scene Graph application, I want to write global user defined function which can be use and call any where in my application. is any way? Please suggest.
Balbant Singh
  • 187
  • 1
  • 10
2
votes
3 answers

Roku SceneGraph - check URL for 404

I'm new to Roku coding and I was wondering if there is a simple Function (non-Task Node) that I can use to check and see if a URL is valid or not and then just return a Yay or Nay so I can check a second URL? Thank you
matrixebiz
  • 97
  • 2
  • 10
2
votes
1 answer

Convert time and date from one time zone to another in Roku SG

I have a particular date and time. Now, I want to convert the time according to device current time zone. Basically what I need is an script that, when provided with a time and a timezone can return the time in another time zone. How can I achieve…
Balbant Singh
  • 187
  • 1
  • 10
2
votes
1 answer

Encrypt String Roku BrightScript

Im newbie in BrightScript, I would like to know how to encrypt the string. can you give me an example? This is my code esn = m.constants.deviceSerialID How to encrypt the result of this? i got research but i don't know how to use and how to put…
Jude Bautista
  • 160
  • 1
  • 16
2
votes
1 answer

How to detect slow connection in ROKU Scene Graph?

The requirement says "Switch to low definition video when connection is slow" I'm wondering is there anyway. Any help would be appreciated
2
votes
2 answers

Is it possible to show the numbers entered in a roPinEntryDialog?

I have a Roku application using roPinEntryDialog, like so: function EnterCode() as Boolean screen = CreateObject("roPinEntryDialog") mp = CreateObject("roMessagePort") screen.SetMessagePort(mp) screen.SetNumPinEntryFields(8) …
Cassidy
  • 3,328
  • 5
  • 39
  • 76
2
votes
1 answer

Roku/scenegraph transparent video overlay makes video darker

I hit quite a big problem trying to overlay a transparent PNG onto video node. It looks like transparency is not applied correctly and the white transparent image makes video darker. Screen grab - video is a white 30 seconds clip. Top rectangles…
kszadkow
  • 41
  • 3
2
votes
1 answer

how to get native stream video resolution in roku/scenegraph?

Is it possible in screen graph to get native stream resolution? or at least its aspect ratio? The Video node is performing automatic scaling padding it vertically or horizontally - I need to know the video size without padding. Thank you in advance…
kszadkow
  • 41
  • 3
2
votes
2 answers

How to implement Deep Linking in Roku SG application?

I need help understanding deep linking, because our Roku Scene Graph application was rejected by Roku. Roku explains deep linking here: https://sdkdocs.roku.com/display/sdkdoc/Deep+Linking, but this documentation is not detailing all information…
Manjeet
  • 191
  • 1
  • 14
2
votes
2 answers

How to replace a PanelSet using replaceChild in BrightScript

I'm using the PanelSet class to create a settings screen made of two panels: panelA on the left-hand side displays a list of overall settings options panelB is displayed on the right-hand side, includes a list of different options for each item on…
heitortsergent
  • 1,971
  • 2
  • 20
  • 23
2
votes
1 answer

How to control the background opacity of progress dialog in Roku scene graph?

I am using main.brs code to show the progress loading dialog . If i use this code for progress dialog then its default background is occupying complete screen. here i want to show only progress loading animation and background should be little…
A.V REDDY
  • 55
  • 6
2
votes
2 answers

roUrlTransfer function not working in BrightScript

I am creating my own channel for Roku. I need to get the streams of my videos and images from a JSON file on a server. Code in my SceneGraph .xml file:
Balbant Singh
  • 187
  • 1
  • 10
2
votes
1 answer

Roku: How to change label text size

Bright script using scene graph. i want to change size of default font without Font node. I used "SmallestSystemFont" font. It appears large font then actual require size.