Support/Forums/BrightSign General Discussion

Script Examples - incl Simple Showcontrol Script

RokuLyndon
posted this on February 22, 2010 05:49 PM



This list isn't in any particular order, or are the scripts organized. I'm going to start adding simple script examples I've been asked about to this thread. There are several script examples in the object reference guide. In some cases, what I post here will be just sample code, not a fully functional script. To run any script posted, it needs to be named autorun.brs (for the compact models) or autorun.bas (for the HD600 and HD2000s) and should be in the root of the flash card. Scripts

  • [b]Video Control Script: UDP & Serial[/b] Readme 9/13/11 This is a control script for playing back videos. It accepts commands over serial or UDP to play, stop, and loop a video. It also supports search and volume controls. The readme contains the list of commands. The unit automatically responds when a command is received, a different response for each command, and it also sends a response when a file has finished playing or each time it finishes playing a video if it's looping. If you're using an AMX, Crestron, or similar show controller and just want to be able to send a command and file name to the brightsign, this is one solution.
  • [b]Play All Videos, NTSC output[/b]3/31/11 This simple script will play all videos found on the flash card. It also sets the video mode to "ntsc-m". If you're using an HD810 or HD1010, you can connect the center component connect to an older display using composite cables. Latest versions of BrightAuthor don't require a script. 
  • [b]Cleans out Recovery script - Deletes the Network Registry[/b] If you connect your Brightsign to Brightsign Network Manager, there's a recovery script stored in the registry. Once this recovery script is enabled, you can't startup a unit with a blank flash card or no flash card and see the firmware version on the screen. Also, with the recovery mode enabled, you can't use the autorun that's built into memory. This script deletes the networking registry and displays text onscreen when complete.
  • [b]3 Zones to 1 and back [/b] This is a simple demonstration script. It plays one video and two images together in a three zone layout. After 18 seconds, the image zones stop, and the video expands to full screen, and then back to three zones after another 6 seconds.
  • [b]Loop any video Script[/b] Loops any number of videos on the card indefinitely. The videomode setting is at the top.
  • [b]Plays one out of 20 videos named video1.ts thru video20.ts[/b] This script accepts gpio input on button zero. If button zero is pressed, it picks a video randomly. When the video is finished, the script returns to a blank screen, and waits for the button press again.
  • [b]Randomly play any mp3 on the flash card when a button 0 is pressed[/b] This script accepts gpio input on button zero. If button zero is pressed, it randomly chooses an mp3 to play. No input is accepted during playback. Once playback is finished, the unit waits for the next input.
  • [b]Synchronize 1 Video over GPIO[/b] This script plays one video in a loop, and synchronizes playback with one or more units connected to the gpio 0 output of the master. It assumes the video is named "video.ts" and that the slave is also listening on input zero.
  • [b]Select an Audio file, blink led during playback[/b] This script plays one of two mp3s when either button 0 or 1 is pressed. During playback, the script flashes an led connected to gpio 4 for audio 1 and for gpio 5 for audio 2. The led flashes on and off every 1/2 second.
  • [b]Installs custom script into memory[/b] This script will place a script named boot.brs into memory, replacing the default autorun.brs. You can put your own script into memory to execute on startup, or put a modified version of the existing autorun back into memory, with any changes you've made to it.
  • [b]Set Date & Time on HD810/HD1010[/b] This is actually a playlist using the older playlist format. Just edit the autoplay.bsp with any text editor and change the timezone and time to match the time you want to manually set. If your HD1010 is on the network, it will use the brightsign timeserver on the internet to set its date and time.

Code Examples

  • [b]Script runs, deletes and replaces itself with a different autorun.brs from a temp folder[/b] This script accepts just prints output to the serial port. It's just a simple test. It will run and delete itself. It will copy an autorun.brs from the /temp folder to the root, and then restart. For example, you could publish a project to your flash card and copy that autorun to the temp folder. Then, you can add a custom script that would run once, and then copy the correct autorun back into the root.

 

 

Comments

User photo
darksigns


Hi Lyndon,

Your Help was great at the scripting with leds thank you. Now I learned some from scripting <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
I have a question:
is there a way to control player trough the serial I mean if I connect with terminal and start a script for example play a video can I stop the playing and get back roku shell?
Do I have to use roSerialPort object?
thx
May 21, 2010 10:11 AM
User photo
RokuLyndon


IF you want to use the shell, then you have to stay in the shell. So, you could send to the shell something like:

videoplay video.mpg

And, it will play that video.


A script gives you more options. You can use the control script I posted to take serial or udp commands for file playback.
May 21, 2010 05:50 PM
User photo
pshea


I'm brand new to BrightSign products (warning!)...I'm using a HD810 and am hoping to accomplish the following:

- User pushes a touchscreen button on the home state media item
- The 810 plays a video selected at random from a list of 10 options
- Each of these videos has touchscreen buttons that take the user to another media state or back to the home state

I have all of this flow currently laid out in BrightAuthor, but am stumped as to how to enable the randomization element upon the initial interaction. I see there are a couple of script samples that you have provided, but I'm unclear as to how or where to integrate them into the existing interactive playlist flow. Please advise!

Thanks.
May 27, 2010 10:07 PM
User photo
base2


Hi, I'm using one of your products for the firs time. I've bought two hd810 and an expander. I'm trying to modify your "video control script" with:

- the option to output sound using the spdif in the expander
- preload the video to synchronize the players.

The first part is done, but I'm totally desperated with the second. I'm trying to implement this under the PLAYCL command with:

m.PreloadFile(m.file_name)
sleep(100)
m.Play()
'm.PlayFile(m.file_name)

what's wrong? I'm totally lost.

any help will be apreciated.

thank you
November 05, 2010 10:11 AM
User photo
BCoudron


Dear all,

I'm using the script "Video Control Script: UDP & Serial Readme 10/26/10" to use it with a Crestron controller but even without changing any-thing, the error leds is blinking 10 times -> script error. I'm using the HD210 with firmware who is now available (not hte beta one)

Any idea?

-> When I comment out the initialize procedure, he's not giving the error (and rebooting)

Best Regards,

Bart
May 18, 2011 11:16 AM
User photo
RokuLyndon


Let me do some testing. What firmware is on your hd210?
May 18, 2011 01:21 PM
User photo
BCoudron


It 's the Version 3.3.78
Official Release
May 18, 2011 04:07 PM
User photo
tonytee


Hi there,

Any light on the issue Bart described last week?
Your SC script really rocks, but half of our Brightsigns don't like it very much....

We have 36 HD1010's (3.5.68) in a current project doing great with your (slightly modified) showcontrol-script and 40 HD210's with the same firmware that instantly start blinking the red error led... Even when I go back to your unmodified v2.8v3g...  I also tried it with FW 3.3.69, which was on the BS's when we got them.
Needless to say we would be very appreciative if you could point us in the right direction...

I have been putting in a reasonable amount of hours now but I can't find what's wrong with it... Being a beginner naturally <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->

Thanks alot, and greetings from the Netherlands...

Keep up the good work...
Tony
May 23, 2011 07:54 PM
User photo
RokuLyndon


I'll get this resolved shortly. There must be some a serial port related call that's used when  on the 210 that's causing the crash..
May 23, 2011 11:38 PM
User photo
RokuLyndon


This has been fixed.

In the newcontrol function, before the checks are done for whether a unit has serial or has ethernet, I didn't initialize control.serialon, and control.networkon. I try to use the serialon variable even though it's not set and that's what caused the hd210 problems.  I've updated the script.
May 24, 2011 12:16 AM
User photo
tonytee


Hi Lyndon,

Thanks VERY much for the overnight support.
You secured quite an important deadline for us...

All 210's are up and running

Cheers, Tony
May 24, 2011 08:15 AM
User photo
BCoudron


Works perfect!

Thanks,

Bart
May 24, 2011 10:54 AM
User photo
BCoudron


Must the dowload work from an external server? The script is responding but nothing happens only the player doesn't respond any more to commands....
What's the lay-out of the downloads.txt file? Filename + CR + LF?

Thanks a lot,

Bart
June 07, 2011 04:25 PM
User photo
RokuLyndon


Yes, just filename plus CR.
It's been a couple months since I tested it, but I know of one customer who has also tested and used this feature. You can turn on debug mode, and capture the serial output from the unit to see what problems it's reporting.
June 07, 2011 04:35 PM
User photo
jawbone78


Lyndon and all Roku Community Techies,

Thank you for posting these scripts. I am a first time Roku user learning through my reseller. While I have accomplished most of what I need, there are some key points with which you could be of great help.

I have an HD1010w along with BA software all updated to the latest versions. I am creating a roughly 20 minute presentation and have some questions. My work is all done and the system is online, but it could be better. (A simple sketch of how I imagine the final product/presentation is included at the end of this post if you want to see how I picture it working.) This will be a long post, but you will be rewarded if you make it to the end.

The 3 Zones To One script may be an answer to my objective. I have a non-interactive presentation in a multizone format and all is going beautifully. However, some of my video content would be much better presented in full screen.

Question #1: Can the script be altered to play some of my video content in full screen before switching back to a multizone presentation, then switch back to play a different set of fullscreen videos, then back to the multizone presentation, etc.? I don't want to play all of the videos at once (there are 15 or more videos ranging from 10 seconds to 45 seconds each), so I am looking for ways to space (batch) them out into small groups... AND keep them full screen... AND still take advantage of the multizone format in between.

Question #2: Assuming I got this to work as I propose, would the resulting complex coding make updating my presentation difficult? Specifically, would I be faced with creating changes in Brightauthor, copying code to my custom script and then manually updating the autorun.brs on the SD card each time I need to publish changes in the playlist content? Or could I find a way to make the user-friendly PUBLISH button do the work for me?

This concludes the first portion of my post, the following question may or may not involve custom scripting but the query does address an expansion to the same concept. Please advise if I need to move the following question to a separate post. If what I ask is possible, I think others would want to know.

In addition, the multizone portion of my overall presentation contains a widget in the main video zone to feed Signchannel news/weather content. However, all of the Signchannel content plays as one long "lump" before allowing BrightSign to move on to the next item in the playlist. There is so much terrific Signchannel content that I cannot use regularly because it prevents the video/image/MRSS content in that zone's playlist from playing often enough. I want to use more Signchannel content without resorting to the limited scheduling options found in the Signchannel web interface.

I would like to break up the Signchannel content into chunks so that only some of the content plays before I move on to the the next playlist item. Minutes later, I want to show different Signchannel content in the same zone. Yes, custom content can be inserted into the Signchannel feed. However, I want to insert custom content into my presentation without using the Signchannel webinterface. (Signchannel doesn't accept video and I want to keep content editing inside of BrightAuthor as much as possible.) Chunking different batches of Signchannel content into roughly 1 minute segments would give me the flexibility to use other content in that zone while allowing for a more cohesive, integrated and engaging mix of messages and content.

Question #3: What would happen if I purchased another Signchannel content subscription and then inserted a second Signchannel widget into the same playlist as the first? Would the system be "intelligent" enough to allow me to assign a different feed to the second widget? Having 2 or more discrete Signchannel feeds in a zone would solve my issue. I would even consider purchasing yet another subscription to use the small-format-friendly stocks/weather feeds in a different smaller side panel zone if Brightauthor allowed Signchannel widgets to be inserted in more than one zone per presentation. Having the option to batch Signchannel content would send my project soaring. I would rather get your opinion on this before spending cash on the experiment, though.

This ends the second portion of my post.  <!-- s:? --><img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /><!-- s:? -->

As promised, here is a rough linear sketch of what I am trying to accomplish on our sign. Imagine you are watching a non-interactive multizone presentation with a main large video/image/Media RSS zone with a roughly 20 minute runtime. This is what I would like to see in that main zone:
Video 01
Video 02
Signchannel Content Batch 01 with weather info
Media RSS feed with my local tides/marine conditions (created in-house)
Live Video Feed (overlooking our harbor)
Video 03
Video 04
Signchannel Content Batch 02 with news/word of the day
Image 01
image 02
Video 05
Signchannel Content Batch 01 again
...and so forth until I have included all my content
Repeat.

This concludes my post. If you read this far, I am so very appreciative and will happily reward anyone who helps with answers to my questions. I will happily pay for a professional relationship to develop my dream, as well. Contact me at jawbone78atyahoo if you are interested. Apologies if soliciting is not kosher here. In the meantime, I will leave you with one of my favorite geeky jokes: Why did the robot cross the road? ...wait for it... Because it was carbon-bonded to the chicken!
August 07, 2011 08:54 PM
User photo
RokuLyndon


Question #1: Can the script be altered to play some of my video content in full screen before switching back to a multizone presentation, then switch back to play a different set of fullscreen videos, then back to the multizone presentation, etc.? I don't want to play all of the videos at once (there are 15 or more videos ranging from 10 seconds to 45 seconds each), so I am looking for ways to space (batch) them out into small groups... AND keep them full screen... AND still take advantage of the multizone format in between.

Answer: Yes, you can modify it so some files play fullscreen.


Question #2: Assuming I got this to work as I propose, would the resulting complex coding make updating my presentation difficult? Specifically, would I be faced with creating changes in Brightauthor, copying code to my custom script and then manually updating the autorun.brs on the SD card each time I need to publish changes in the playlist content? Or could I find a way to make the user-friendly PUBLISH button do the work for me?

Answer: The 3 zone to 1 script I posted is fully customized, so it's not someothing you can just stick in into the brightauthor script. I'm thinking this would have to be a fully customized script, so no brightauthor use.



Signchannel does actually accept video. You might have an old signchannel script on the brightsign if it doesn't for you. But, you should be able to upload video to your signchannel account. The signchannel script is a separate beast. I'm sure it's possible to break up their stream, but I can't say at the moment how it would work, or how much effort it would take. And, adding the signchannel code to a custom script would itself be a task.


Question #3: What would happen if I purchased another Signchannel content subscription and then inserted a second Signchannel widget into the same playlist as the first? Would the system be "intelligent" enough to allow me to assign a different feed to the second widget? Having 2 or more discrete Signchannel feeds in a zone would solve my issue. I would even consider purchasing yet another subscription to use the small-format-friendly stocks/weather feeds in a different smaller side panel zone if Brightauthor allowed Signchannel widgets to be inserted in more than one zone per presentation. Having the option to batch Signchannel content would send my project soaring. I would rather get your opinion on this before spending cash on the experiment, though.


Answer: Signchannel doesn't allow you to add two subs to the same unit, as far as I know. If you were just using media rss feeds, you could add more than one feed to the same zone, with other content in between. BUt, that's in brightauthor. It could be done with a custom script as well.

If you can write up as detailed a description of what you want to do, as well as how it would be updated, I can submit it internally for some feedback to see if it's something we can do, if maybe there's a better way to do it than I've considered, and how much it would cost to do. You can email us at <!-- e --><a href="mailto:support@brightsign.biz">support@brightsign.biz</a><!-- e -->.
August 10, 2011 04:05 AM
User photo
Alfonso Descalzo


I´m developing a Visual Studio aplication to use with the BrightSign

I´m using the ShowControl script with an HD-1010 and the 3.8.24 firmware version.
I´m doing it to use by UDP, although is possible to use it with RS232 too..

It works fine for videos, audio and images. Even I can play audio and images at the same time, so it´s perfect...

But when I use an USB memory, it works fine for videos, but gives me an error when i try it with audio files (didn´t try with images)

Is there anyway to do it work for audio files too?

txs
March 13, 2012 07:34 PM
User photo
RokuLyndon


It's possible the script isn't searching the usb stick for other file types. Send me the version of the script you're using, and I'll make the change to it. Send it to support @ brightsign. biz.
March 14, 2012 10:57 PM
User photo
Alfonso Descalzo

Do these scripts work on new units? (HD220, HD1020....)

September 10, 2012 05:30 AM
User photo
BrightSign Support
BrightSign Support

Which script are you referring to? Most of them need to be modified to work on the new HD units.

September 10, 2012 06:37 AM
User photo
Alfonso Descalzo

I need to use the Video Control Scrip : UDP& Serial for use it with Medialon.

I don´t know if just changing the unit references ("if control.modelObject.GetModel() =") into the script, it will work..

Txs

 

September 10, 2012 07:26 AM
User photo
Alfonso Descalzo

Finally i made it work as I told you, but i can´t find a way to set video mode to the new availables video modes. (i.e composite/PAL mode)..

September 11, 2012 01:36 AM
User photo
Sr. Support America
BrightSign Support

Here's an updated version of the script, that includes the newer players.

 

There's a vvolume command for video volume. 

September 11, 2012 08:23 AM
User photo
Jacco

Do I understand correctly that the last posted script is working for the HD1020? And what about the new XD product line.

November 15, 2012 01:06 AM
User photo
Jacco

We got the showcontrol script working for the HD1010, Just wondering if it will also work on the HD220 and HD1020 since the HD1010 is not available anymore

November 15, 2012 04:57 AM
User photo
Sr. Support America
BrightSign Support

IT doesn't have the xd models in it yet, but it's a simple change to add that. There's a function that does a model check to see if the model has serial or ethernet. And, yes, it works with the 20 series. 

November 15, 2012 05:56 AM
User photo
broenni

Hello

Is the "Loop any 1 .mpg video Script" no longer working with the new 20 series?

The download link is 404

 

 

 

 

 

November 28, 2012 06:10 AM
User photo
Sr. Support America
BrightSign Support

Try the new link

November 28, 2012 04:12 PM
User photo
Peter

Is the videoloop script running files at 25 images/sec? Could you post the script for videolooping a HD file (fullHD) at 25 images/sec? (the older script from last year doesn't work with the new firmware...  Thanks!!

December 16, 2012 03:35 AM
User photo
BrightSign Support
BrightSign Support

Please send your old script that doesn't work.

December 16, 2012 03:42 AM
User photo
Peter

This autorun only seems to run with mpg (Mpeg2) files. It doesn't play a MP4 file (compressed as H264), changing the extension to .mov doesn't help... Any ideas? 

December 16, 2012 12:17 PM
User photo
BrightSign Support
BrightSign Support

That could be because your mp4 video is out of supported specs.

December 17, 2012 02:26 AM
User photo
tingo

Hi there,

We have a project with 8x HD1010. Always two players form a group that should synchronize in it.
Every group has four movies that sould be started over network (mediacontroller) with the showcontrol script over UDP.
With an BrightAuthor Project it works, but we like to have a simple script like the simple master/slave Script  we found on the Roku forum (a simple Script, because we have to replace the movies often and that should be made easy). The Issue we have, is that we have more than one track to play in a group. All 8 players are connected to the same network, fixed IP adresses, no DHCP.

Is there any script we didn't found yet that's able to work as a "control script slave" ?

thanks for your answer!

December 18, 2012 11:56 PM
User photo
BrightSign Support
BrightSign Support

The easy way to replace the content in brightauthor presentation: open an existing presentation, go to File - Replace Media Files, browse to a folder with new content, replace files, click OK, and publish a presentation.

December 19, 2012 12:41 AM
User photo
tingo

Thanks for your answer. We don't like to use BA.
In this 2 years old installation we have still more single players, totally 16 pcs of HD-810. All are equipped with the showcontrol script and controlled over RS-232 and a Moxa Serial Server on the same network. So we like to add the new 8 players with the same logic (naturally without the Moxa) and the same way to manage the content and control the players. It's used in an museum, not in a signage application. So we use the network only to control the units. Thats the reason why we look for a simple script in slave modus.

December 19, 2012 12:58 AM
User photo
Jeff Marshall

I had attempted to combine two of the examples above  Video Control Script: UDP & Serial and 3 Zones to 1 and back  in order to switch zones using UDP datagrams. I would also like to take advantage of the other functionality in the video control script since there are lots of handy things in there. 

The layout I have attempted has the video object and an html element. Switching is working fine, except when a signal is sent in to play a new video, the video plays fine however the html objects disappear and don't come back until the zone is switched again.

Here is a sample of the code where the layout is switched. It is from the block of else if conditions that evaluate the udp datagram after it has come in:

else if command = "LAYOUT0" then
fullscreen=false
m.SendResponse("LO0")
r = CreateObject("roRectangle",0,0,550,1080)
m.h0 = CreateObject("roHtmlWidget",r)
m.h0.EnableSecurity(true)
m.h0.EnableMouseEvents(false)
m.h0.SetURL("http://192.168.20.2/application/client/Events.php")
m.h0.show()
r = CreateObject("roRectangle",550,0,1370,770)
r = CreateObject("roRectangle",1464,770,456,240)
m.h1 = CreateObject("roHtmlWidget",r)
m.h1.EnableSecurity(true)
m.h1.EnableMouseEvents(false)
m.h1.SetURL("http://192.168.20.2/application/client/weather.php?city=Chicago%20c...)
m.h1.show()

If you can shed any light onto this problem it would be appreciated.

 

Thanks,

Jeff

June 13, 2013 08:25 AM
User photo
BrightSign Support
BrightSign Support

Jeff,

Why did you decide to write a script instead of creating such a project in BrightAuthor?

These 2 videos show how to send udp commands to and from the brightsign unit:

https://www.brightsignnetwork.com/download/Videos/Amx-Crestron-Cont...

https://www.brightsignnetwork.com/download/Videos/ba2.2_advanced_se...

This faq explains how to switch between the different projects using interactive event:

http://support.brightsign.biz/entries/21121606-How-do-I-switch-pres...

June 14, 2013 04:19 AM
User photo
Jeff Marshall

When we spoke to the sales person we were told that we could display content dynamically from an external file system. That is, can someone place files on a local server and have bright sign play the image or video by using a udp datagram sent from an app also on the network? Can this be done from Bright Author? 

From my investigations it can not be done within Bright author. I would be glad to be corrected by you on this. I can appreciate that you want people to use the tool you have created. But so far the tool does not do what we want.

If this cannot be solved in bright author then I am forced to solve it with script. Which brings me to my original question.

Why is it that any interaction with the video in script hides the html elements? Does creating a video place it over top the html elements? if so how is layering handled?

June 17, 2013 07:45 AM
User photo
Sr. Support America
BrightSign Support

When you say external file system, do you mean on a file/web server on the local network?  It's not clear to me what you're trying to do. No, a video zone isn't automatically over an html zone. I know this because we did a project at infocomm with an airport way find done all in html except for the video that played in the background was in a standard video zone. 

June 17, 2013 07:48 AM
User photo
Sr. Support America
BrightSign Support

In the script you are using is zones supported enabled. There should be a command like: EnableZoneSupport(true). 

 

June 17, 2013 07:53 AM
User photo
Jeff Marshall

Ok... Let me put it to you this way. A person has an iPad. The person can select from predefined layouts to be displayed on the Bright Sign. The person can then use the app to play what they would like to see in any of those zones. in each zone there may be hundreds of videos and hundreds of images to choose from, plus a weatherbug, events from the web, calendar etc. All of this content is too much for a project in bright author. besides it would be arduous putting conditions on all of those files individually. So we have a server located on the local network serving media.

I have EnableZoneSupport(true) placed in the beginning. I don't believe you have to call it more than one am I right?

As of this moment I am using your the ideas in the  zone switchiing script put into the UDP video control script. Where the command is being evaluated I am also evaluating the datagram to check which layout should be presented. Then using the video control scripts to play the selected video from a file. The filename and location to be passed in through a datagram using the play <filename> function. 

Do you have a way to handle this in Bright Author? If not how would you suggest we proceed.

 

June 17, 2013 08:36 AM
User photo
Jeff Marshall

I found it. In the play function it was m.image.StopDisplay() that cleared out the html elements.

June 17, 2013 01:45 PM