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
0
votes
1 answer

Is it possible to disable buttons in roMessageDialog?

I want to show a roMessageDialog with some disabled buttons in a Roku app. Is that possible? I can't find anything in the documentation that says so.
Otavio Macedo
  • 1,542
  • 1
  • 13
  • 34
0
votes
1 answer

How to get JSON values using variable in brightscript

I am trying to parse this JSON using a variable to represent the value, but it isn't working. I don't know if it is because the variable isnt representing the string or if I just can't do what I am trying to do. Function get_categoriesItems(category…
Joe Rocca
  • 178
  • 1
  • 10
0
votes
1 answer

how can i make a hex string from integer value in Brightscright?

I have written an Int 2 Hex function and was wondering if this is the best way https://gist.github.com/kaayr1m/cacd3432b53fd854b0de are there any other ways to do this? ' @param intValue positive integers from 0 onwards function…
Karim
  • 415
  • 6
  • 14
0
votes
1 answer

Roku: Infinite wait on POST request with roUrlTransfer

I am trying to send a POST request to an address with some parameters. The app is waiting on the port and not moving forward at all. What am I doing wrong and how do I fix this? Sub LoginUser() obj = {} obj.username = "scb@test.com" …
khateeb
  • 5,265
  • 15
  • 58
  • 114
0
votes
1 answer

Unspecified or invalid track path/url - Roku with Livestream.com stream

I'm developing a custom Roku channel and I need to use a livestream.com video stream from the following live stream event: http://livestream.com/accounts/11222132/events/3665575 Using their json service I've been able to obtain an m3u8 stream. The…
Ohiovr
  • 977
  • 1
  • 12
  • 22
0
votes
1 answer

Play Video with redirect url

In our channel we have a url to play videos that does a last check for authentication then redirects to the CDN url and that plays a video. This was all done over http in all of our test channels and works great. The problem is when we deployed to…
Scott Selby
  • 9,420
  • 12
  • 57
  • 96
0
votes
1 answer

Roku animation using animated sprites, how to create the tedious xml

I made a simple java script code to create the sprite sheet xml for the sprite animation in roku written in brightscript. Is there an easier way to just pass in the sheet and let it figure out the dimensions of the frame? That would be cool. I…
Karim
  • 415
  • 6
  • 14
0
votes
1 answer

Checking for button title overflows in Brightscript

In Roku's library, to add a button to a spring board screen, you use the method (see doc): AddButton(buttonID as Integer, title as String) as Boolean If title overflows the button width, it will automatically truncate the text and append "...". But…
Otavio Macedo
  • 1,542
  • 1
  • 13
  • 34
0
votes
2 answers

Change default font roFontRegistry in Roku

I have created a page with roImageCanvas ,and i am trying to change its default font with another one.bellow is my code but this won't work.Please help me to resolve this error.thanks in advance. canvas = CreateObject("roImageCanvas") port =…
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
0
votes
1 answer

Adjust spacing between text lines brightscript

Bellow is the code to show a string in Roku using roImageCanvas canvas = CreateObject("roImageCanvas") port = CreateObject("roMessagePort") canvas.SetMessagePort(port) items = [] items.Push({ Text: "Lorem Ipsum is simply dummy text of…
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
0
votes
4 answers

Convert seconds to Hour:Minute:Second brightscript

I need to convert seconds to Hour:Minute:Second. For example: 685 converted to 00:11:25 How can I achieve this? I can't find a method from brightscript…
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
0
votes
1 answer

Brightscript: how to pull my Youtube videos from my own channel onto the Roku?

I'm making a youtube channel for some meteorologists who hired me for an internship. They want to use Youtube to pull their videos and display them onto the Roku Channel. How would I do this? also, I need to make a list of the videos from the…
Capson
  • 13
  • 3
0
votes
2 answers

How to set a background image in BrightScript for a particular screen?

How to set a background image in brightscript for a particular screen? Is dfNewBitmapSet() the method used to set the background?! kindly share your answers
0
votes
1 answer

Generate Expiring AWS S3 URL links in Brightscript

Can someone point me to some documentation of utilizing brightscript to generate expiring AWS S3 urls with AWSaccesskey to append to video links from an XML feed. example:…
0
votes
1 answer

roUrlTransfer 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 from a server. I found a couple of examples of how to do that using roUrlTransfer component, but all those examples tell that you need to have…
User555
  • 83
  • 1
  • 9