The following global helper functions are available in the script API.

Function

Description

createRichText (plainText: string, escape?: boolean): RichText

Creates a RichText object that can be assigned to the Formatted field type.
plainText: The plain text for the created object.
escape: If true (default), escapes the given text when creating the RichText (so that < and > characters are properly displayed).

createImageAsset (image: string, title?: string): ImageAsset

Creates an ImageAsset object that can be assigned to Image fields.
image: External URL, Graphic Hub image path or UUID.
title: A title used for the image. It is not required for GH images.

createVideoAsset (video: string, title?: string): VideoAsset

Creates a VideoAsset object that can be assigned to Video fields.
video: Local file path to a clip. The file path must be accessible from the Viz Engine.
title: A title used for the clip.

reportErrors (f: () => void, stage: string): void

Transmits possible errors (exceptions) occurring within a callback/async call, to the UI.
Usage sample: fetch( ... ).then( ... ).catch( e => reportErrors(() => { throw e }, "fetch step") )

Examples

Image fields can be assigned by using the createImageAsset method. This method accepts any of the three input references to an image: UUID or path to an image on the Graphic Hub, or a full URL to an image:

vizrt.fields.$insta.$image2.value = createImageAsset("IMAGE*&lt;520E0100-56BD-5C4D-884D-5598ACFD75A4&gt;")
vizrt.fields.$insta.$image2.value = createImageAsset("IMAGE*01_GLOBALS/IMAGE/logo_wide")
vizrt.fields.$insta.$image2.value = createImageAsset("https://images.pexels.com/photos/169647/pexels-photo-169647.jpeg", "HEY")

Video fields can be assigned by using the createVideoAsset method. This method accepts a full path to a clip on a disk:

vizrt.fields.$00Video.value = createVideoAsset("C:\\clips\\CVJPHFMXDHBGZFMF.mxf", "Title")

The file path must be accessible on the Viz Engine that plays out this clip.

Formatted Text fields can be assigned by creating an object of type RichText in the method createRichText:

vizrt.fields.$name.onChanged = value => {
vizrt.fields["$01-richtext"].value = createRichText(
`<fo:wrapper bold="false" italic="false" underline="false">Hello </fo:wrapper>` +
`<fo:wrapper bold="true" italic="true" underline="true">${value}!</fo:wrapper>`, false)
}

Info: The second argument to the method is set to false. This ensures the formatted text is sent to the Viz Engine unescaped. If set to true, the text is escaped, but the formatting is lost.

false: When the actual RichText XML should be sent to the Viz Engine.
true: When the text does not contain RichText, but contains characters that require escaping, such as < and >.