Performing Scripting Actions

A scripting language is programming language that supports scripts, programs written for a special run-time environment that can interpret (rather than compile) and automate the execution of tasks. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), and embedded systems.

One of the most powerful aspects of Ooyala Flex is its support for scripting. Through scripting, developers can use simple well known Javascript-like syntax to make the behaviour of Ooyala Flex more dynamic and extensible.

• Create brand new actions, timed actions, and event handlers in a matter of minutes.

• Defer evaluation of configuration values to run-time.

• Access Ooyala Flex's API and created sophisticated new functionality without deploying compiled code.

• Make extremely dynamic workflows that adapt depending on real-time data.

• Create dynamic transcode and validation profiles.

Ooyala Flex supports three types of scripting languages to support three different scenarios. The first two are specialised to support specific use cases. The third one (Groovy) is an extremely powerful general purpose language.

Expression Language (EL): Expression Language is used for more advanced configuration. It can be used in configuration fields and supports Ooyala Flex object access and common language operators.

Velocity Template Language (VTL): Velocity Template Language is a templating language used for converting document from one format to another. This scripting is used for creating low level transcode profiles.

Advanced Scripting (Groovy Script): Advanced scripting is supported in special scripting plugins (actions, event handlers, timed actions). Through using scripting plugins developers can implement advanced script-based extensions to Ooyala Flex's functionality. Ooyala Flex uses GroovyScript for this purpose, which is a Java-based language that offers advanced object-orientated programming paradigms and full access to the Java SDK. It also offers complete access to Ooyala Flex's API.

Script Processing

In this scripting guide, it will be shown that scripting can be layered, such that different scripting languages can be used in the same code. For example you may choose to embed some expression language inside some Groovy script. In this case, the Expression Language is processed first and the output code is them passed to the Groovy script engine for further processing. The order in which script are processed is as follows:

1.) Properties Expressions

2.) Metadata Expressions

3.) Expression Language

4.) Groovy Script

An example of this is shown below. Here some Expression Language has been embedded in some Groovy Script.

def execute(){

//Reference asset Object in the context asset name

to the description.



Understanding Scripting Actions

The value of an expression in static text is computed and inserted into the output.

There are three ways to set a value:

1.) With a single expression construct: $ {expr}. The expression is evaluated and the result is coerced to the expected output type.

2.) With one or more expression separated or surrounded by text: some$ {expr}${expr}text$ {expr}. The expressions are evaluated from left to right. Each expression is coerced to a String and then concatenated with any intervening text. The resulting String is the coerced to the expected output type.

3.) With text only: sometext

In this case, the string value is coerced to the expected output type.


Understanding Advanced Scripting

As well as standard Expression Language, Ooyala Flex also offers some advanced features for the creation of more advanced evaluation.

• Metadata Expressions

• XPath Expressions

• System Properties

Metadata Expressions

Ooyala Flex supports some operators that assist with locating metadata field values within asset hierarchies:

Expression Explanation
@@fieldname@@ Expression starts with @@ and ends with @@. Using this expression we can access metadata variable values. e.g. @@film_id@@ - returns value of film_id variable from metadata associated with current asset.
%%assetContext%% Metadata Expressions also support embedded asset hierarchy expressions. These start with %% and ends with %%. If we want to retrieve values from parent or child metadata than we can also specify the asset hierarchy expressions e.g. @@%%./..%%artist[0]:first_name[0]@@ - evaluates metadata expression "artist[0]:first_name[0]" against metadata of parent.

XPath Expressions

Ooyala Flex supports some operators that assist with locating XML field values from a raw XML documents ("document") that exist within a scripting context.

Expression Explanation
@!{xpath} Using this expression we can evaluate xpath against xml e.g. @!{/work-order/transcode-profile/name} - evaluates xpath "/work-order/transcode-profile/name" against xml document. Xpath expressions are evaluated against document Objects available as a variable in the context with "document" key. If any xml document is available in context then it will get added as a variable automatically so xpath expressions defined would be resolved against this xml.

System Properties

Expression Explanation
@[propertyName] System Properties are variables that are available in the Ooyala Flex system. Super Users can create their own System Properties, that can be accessed through Scripting. System Properties support scoping.