Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Expand
titleTable of Contents
Table of Contents
minLevel1
maxLevel3
outlinefalse
indent20px
typelist
printablefalse

This page describes how to use two advanced BrightAuthor and BrightAuthor:connected features: custom autorun plugins and parser scripts. These instructions assume a certain level of familiarity with BrightScript. This is not a comprehensive guide to writing custom scripts for BrightAuthor or BrightAuthor:connected; it is meant to provide a general outline and best practices for writing those scripts.

Overview

Plugins allow you to add script extensions to a standard presentation autorun. Plugins have two primary benefits over custom autoruns:

  • They can be easily inserted into multiple presentations, including newer and older versions of the same presentation.

  • They are not dependent on a certain autorun or firmware version, greatly reducing the complexity involved in updating custom BrightScript deployments.

BrightAuthor:connected Autorun Plugins

To designate one or more custom plugins in BrightAuthor:connected:

  1. If you are a Content Cloud user, upload your plugin to the server through the Content upload (see https://brightsign.atlassian.net/wiki/spaces/DOC/pages/384958989/Content#Scripts). If you are a Control Cloud user, skip directly to step 2 to add a plugin to the presentation.

  2. Attach it to your presentation (seehttps://brightsign.atlassian.net/wiki/spaces/DOC/pages/404623943/Presentation+Settings#Script-Plugin%5BinlineExtension%5D)

  3. If needed, refer to Plugin Message Eventto trigger state changes.

BrightAuthor Autorun Plugins

Note

BrightAuthor (classic) versions that are older than 3.7 do not support plugins.

...

  1. Navigate to File > Presentation Properties > Autorun.

  2. Select the Add Script Plugin button.

  3. Give the plugin a name (which must be the same as the <plugin_name> described in the initialization function below).

  4. Select the Browse button to locate and select a .brs file to use as a plugin.

Plugin Structure

Plug-in scripts must include an initialization function in the form of <plugin_name>_Initialize(). Actions that take a lot of time should not be done in the initialization routine, because actions in the routine are synchronous. Instead, start a timer that will be caught by the plugin event handler soon after the routine runs, and execute the longer code segment there. For example, instead of unzipping a file in the initialization routine, do it through the plugin event handler with a timer started in the routine.

...

Code Block
Function pizza_Initialize(msgPort As Object, userVariables As Object, o As
Object)

    print "pizza_Initialize - entry"
    print "type of msgPort is ";type(msgPort)
    print "type of userVariables is ";type(userVariables)

    PizzaBuilder = newPizzaBuilder(msgPort, userVariables)

    return PizzaBuilder

End Function

Function newPizzaBuilder(msgPort As Object, userVariables As Object)

    PizzaBuilder = { }
    PizzaBuilder.msgPort = msgPort
    PizzaBuilder.userVariables = userVariables
    PizzaBuilder.objectName = "PizzaBuilder_object"

    PizzaBuilder.ProcessEvent = pizza_ProcessEvent

    return PizzaBuilder

End Function

Function pizza_ProcessEvent(event As Object)

    print "pizza_ProcessEvent - entry"
    print "type of m is ";type(m)
    print "type of event is ";type(event)

' swallows timer events - telling the autorun not to process them
    if type(event)= "roTimerEvent" then
       return true
    else
       return false
    endif

End Function

Receiving a Plugin Message

The following example code shows how to write a script that receives a Send Plugin Message Command from the autorun. This code listens for a message sent to the plugin named “Pizza” and then prints the message:

Code Block
Function pizza_ProcessEvent(event As Object)

    print "pizza_ProcessEvent - entry"
    print "type of m is ";type(m)
    print "type of event is ";type(event)

    if type(event) = "roAssociativeArray" then
        if type(event["EventType"]) = "roString"
            if event["EventType"] = "SEND_PLUGIN_MESSAGE" then
                if event["PluginName"] = "Pizza" then
                    pluginMessage$ = event["PluginMessage"]
                    print "received pluginMessage ";pluginMessage$
                    return true
                endif
            endif
        endif
    endif

    return false

End Function

Sending a Plugin Message

The following example code shows how to write a script that sends a message string to trigger a Plugin Message event.

Code Block
print "pizza_ProcessEvent - entry"
    print "type of m is ";type(m)
    print "type of event is ";type(event)

    if type(event) = "roTimer" then

        pluginMessageCmd = CreateObject("roAssociativeArray")
        pluginMessageCmd["EventType"] = "EVENT_PLUGIN_MESSAGE"
        pluginMessageCmd["PluginName"] = "Pizza"
        pluginMessageCmd["PluginMessage"] = "toppings"
        m.msgPort.PostMessage(pluginMessageCmd)
        return true

    endif

    return false

End Function

Parser Scripts – RSS

Parser scripts allow you to manipulate data sets from incoming RSS feeds. You can create RSS parser scripts for a wide array of system and presentation functions. You can designate a parser for an RSS feed by navigating to File > Presentation Properties > Data Feeds in BrightAuthor.

Warning

Important

The parser file must have a .brs extension.

...

Code Block
        xml = CreateObject("roXMLElement")
        if not xml.Parse(ReadAsciiFile(xmlFileName$)) then
               print "xml read failed"
        else
               if type(xml.channel.item) = "roXMLList" then
                       index% = 0
                       for each itemXML in xml.channel.item
                               itemsByIndex.push(stri(index%) + " - " + itemXML.description.GetText())
                               index% = index% + 1
                       next
               endif
        endif

end Sub

Parser Scripts – MRSS

You can use a script to parse non-MRSS feeds and provide the data in a format that can be used by Media RSS Feed states in BrightAuthor. To designate a parser for an MRSS feed, navigate to File > Presentation Properties > Data Feeds in BrightAuthor.

Warning

Important

The parser file must have a .brs extension.

...

  • fileName$: The name of the feed file to be parsed. This value is provided by the presentation autorun.

  • items: An array of associative arrays representing MRSS items to be played by Media RSS Feed states. This array is empty upon entry to the parser subroutine and should be filled by the script. When the parser subroutine exits, the autorun will supply the data in the array to Media RSS Feed states for playback. See the Item Array Specification section below for a list of associative-array parameters.

  • metadata: An associative array containing optional metadata items pertaining to the entire playlist/feed.

Items Array Specification

The parser script should add associative arrays to the items array–each associative array represents a single media item to be played back. The order of items in the array specifies the order of playback.

...

Key

Value

Example

Notes

url

A download URL for the file

"www.brightsign.biz/images/myfeedpic1.jpg"

Required – The item will be ignored if this value is not present.

medium

video | image | audio | document

"video"

Suggested – If the medium and type values are not present, the medium value will default to "image".

type

video/*, audio/*, image/*, text/html, application/widget

"video/*"

Suggested – If the medium and type values are not present, the type value will default to "image/*".

duration

The display duration in seconds

"30"

Optional – This value applies to images only, and has no effect on other media types. If not specified, this value defaults to "15".

title

The value for the MRSS Title field

"myfeedpic1"

Optional

description

The value for the MRSS Description field

"$5.99"

Optional

size

The size of the file in bytes

"942061"

Optional

guid

A unique value for the file

"ab05caf"

Optional – When this value changes, the player will re-download the file.

mrssCustomFields

An associative array of arbitrary key-value pairs

{key1:"custom field A", key2:"custom field B"}

Optional – Use this associative array to include custom MRSS fields.

Metadata Specification

The metadata object is an empty associative array when the parser subroutine is entered. This associative array can accept optional key-value pairs that represent properties for the entire feed. All values must be strings–including numerical values. The following table outlines accepted key-value pairs:

...