Developer Portal
Quick StartsComposition scriptingAPIs and SDKsSupport
  • Portal overview
  • Quick start
  • REST API
    • Introduction
    • Rate limits
    • Authorization
    • How-to guides
      • Get a control app's API token
      • Get a composition's sub-composition IDs and names and their payload structures
      • Get a control app's model
      • Get a control app's metadata
      • Update a sub-composition's content
      • Update a sub-composition's animation state
      • Update a sub-composition's content and animation state in one call
      • Update multiple sub-compositions in one call
    • API reference
      • Get control app details
        • Get a control app's metadata
        • Get a control app's model
        • Get a control app's control data
      • Send data to a control app
        • Update a control app's content
        • Update a control app's animation state
      • Take out all of an app's output
  • Data stream API
    • Introduction
    • Rate limits
    • Authorization
    • How-to guides
      • Create a data stream
      • Link a data stream to a composition
      • Send data to an app using the data stream API
    • API reference
  • Composition scripting
    • Introduction
    • Overview
    • Quick start
      • Find sub-compositions and widgets
      • Read and update control nodes
      • Set text widget text properties
      • Read and update widget properties
      • Read control nodes and update widget properties
      • Set image widget URL property
      • Set table widget content property
    • Cheat sheets
      • Fundamentals
      • Interactive overlays
      • Best practices
    • Use cases
      • Read control nodes and generate HTML text
      • Read control nodes, generate HTML text with background
      • Text Ticker - Start ticker on "In" animation
    • Composition script editor reference
  • Software development kits
    • Graphics SDK
      • Getting started
      • Reference
        • SDK functions
        • Composition object
        • Sequencer object
      • Guides and examples
        • Load a composition with its token
        • Load a composition with its URL
        • Get the composition URL of an app instance
        • Sequencer VOD example
        • Control local preview of app
        • Load app instance output
    • Overlay SDK
      • Getting started
      • SDK functions
      • Use case examples
    • Widget SDK
      • Preparing your environment
      • Getting started
      • Reference
        • Widget UI definition
        • Widget callback functions
        • Time control object
        • Composition instance
      • Guides and examples
        • Widget example: CSS patterns
    • App SDK
  • Singular Basics
    • Overview of Singular
    • Managing overlays in the Dashboard
      • How to create a new composition
      • How to open a new app template
      • How to create an app for a composition
      • How to extract a composition from an app
      • How to find an app's shared app token and shared API URL
      • Dashboard reference
    • Building overlays in Composer
      • How to build a composition
      • How to set up layer logic to automate overlay transitions
      • How to set up control nodes to make widget properties available to a control app
      • Animating overlays
        • How to create timeline animations
        • How to create behavior animations
        • How to create update animations
      • How to make overlays interactive
      • How to adapt overlays to various screen sizes
      • Composer reference
    • Controlling overlays in Studio and UNO
      • How to use Studio
      • Studio reference
      • UNO reference
  • Support
    • Singular status
    • Support resources
    • Singular terminology
    • Performance Testing
Powered by GitBook
On this page
  • SingularGraphics(domElement)
  • SDK properties
  • SDK functions
  • addListener
  • getAdaptationGlobals
  • getCompositionById
  • getCompositionInfo
  • getConfig
  • getMainComposition
  • getSequencer
  • loadComposition
  • noTrack
  • onmessage
  • removeAllListener
  • removeListener
  • renderAppOutput
  • renderComposition
  • setAdaptationGlobals
  • setConfig
  • setFrameNumber
  • videoCommand

Was this helpful?

  1. Software development kits
  2. Graphics SDK
  3. Reference

SDK functions

SingularGraphics(domElement)

Use the following code to create an instance of a Singular overlay:

const overlay = SingularGraphics("SingularOverlay");
Attributes
Type
Required
Description

domId

String

Yes

The target div that the SingularOverlay will replace.

SDK properties

Name
Type
Example
Description

host

String

"https://app.singular.live"

Domain of the SDK player client.

id

String

"SingularOverlay"

iframe ID.

const compMain = overlay.getMainComposition();
console.log("compMain =", compMain);

Return

object: Graphic SDK object

overlay:
> addListener: Æ’ (event, callback)
> getAdaptationGlobals: Æ’ ()
> getCompositionById: Æ’ (compId)
> getCompositionInfo: Æ’ ()
> getConfig: Æ’ ()
> getMainComposition: Æ’ ()
> getSequencer: Æ’ ()
> host: "https://app.singular.live"
> id: "SingularOverlay"
> loadComposition: Æ’ loadComposition(compositionId, cb)
> noTrack: Æ’ ()
> onmessage: Æ’ (e)
> removeAllListener: Æ’ ()
> removeListener: Æ’ (event, callback)
> renderAppOutput: Æ’ renderAppOutput(appId, output, cb)
> renderComposition: Æ’ renderComposition(compositionObject, cb)
> setAdaptationGlobals: Æ’ setAdaptationGlobals(data)
> setConfig: Æ’ (_config)
> setFrameNumber: Æ’ setFrameNumber(frame)
> videoCommand: Æ’ videoCommand(cmd, time)

SDK functions

The reference documentation provided in the following sections describes the Graphic SDK structure and methods.

Method
Return type
Description

-

Adds an event listener.

Object

Returns adaptation global parameters.

Object

Returns the composition object requested by its ID.

Object

Returns a detailed description of a composition's structure, control and data nodes, animation, and timeline states.

Object

Returns configuration details.

Object

Returns the main composition object.

Object

Returns the sequencer object.

-

Loads a composition defined by its ID or JSON URL.

-

Deactivates tracking of analytics.

-

Depreciated.

-

Removes all event listeners.

-

Removes an event listener defined by its name.

-

Loads a composition defined by its app ID.

-

Loads the composition defined in a composition object.

-

Sets adaptation global parameters.

-

Sets configuration properties.

-

Depreciated.

-

Depreciated.

addListener

Adds a listener for events coming from the overlay.

overlay.addListener(type, callback);
Attributes
Description
Type
Required

type

A string containing one of the values described below

String

Yes

callback

The callback function for the type of event

Function

Yes

Values for listener type

Setting
Description

payload_changed

Listens to messages from control node updates.

datanode_payload_changed

Listens to messages from data node updates.

state_changed

Listens to messages for animation state changes.

message

Listens to messages from the interactive events and widgets.

error

Listens to errors reported by overlay instances.

See also:

payload_changed

Listens to payload_changed from control node updates.

overlay.addListener('payload_changed', (event, msg) => {
  console.log("Composition payload changed:", event, msg);
});

Callback attributes

Attributes
Type
Description

event

String

The event name.

msg

Object

JSON data containing event details.

{
  "compId": "your-composition-id",
  "compName": "your-composition-name",
  "compositionId": "your-composition-id",
  "compositionName": "your-composition-name",
  "payload": {
    "your-control-node-ids": "your-control-node-values"
  }
}

datanode_payload_changed

Listens to datanode_payload_changed from data node updates

overlay.addListener('datanode_payload_changed', (event, msg) => {
  console.log("Composition datanode payload:", event, msg);
});

Callback attributes

Attributes
Type
Description

event

String

The event name.

msg

Object

JSON containing event details.

{
  "id": "your-datanode-id",
  "name": "your-datanode-name",
  "payload": {
    "your-datanode-ids": "your-datanode-values"
  }
}

state_changed

Listens to state_changed for animation state changes.

overlay.addListener('state_changed', (event, msg) => {
  console.log("Composition state changed:", event, msg);
});

Callback attributes

Attributes
Type
Description

event

String

The event name.

msg

Object

JSON containing event details.

{
  "compositionId": "your-composition-id",
  "compositionName": "your-composition-name",
  "state": "In" | "Out" | "Out1" | "Out2"
}

message

Listens to message from interactive events and widgets

overlay.addListener('message', (event, msg) => {jaconsole.log("Composition message:", event, msg);
});

Callback attributes

Attributes
Type
Description

event

String

The event name.

msg

Object

JSON containing event details.

{
  "event": "custom",
  "params": {
    "compId": "your-composition-id",
    "id": "your-widget-id",
    "name": "your-widget-name",
    "widgetId": "widget-id",
    "type": "type-of-message-sender",
    "data": {
      "JSON-object-with-custom-data"
    }
  }
}

error

Listens to error reported by an overlay instance.

overlay.addListener("error", (params) => {
  console.log("Error:", params);
});

Callback attributes

Attributes
Type
Description

params

Object

JSON containing error details.

getAdaptationGlobals

Makes a request to get adaptation global settings.

const adaptationGlobals = overlay.getAdaptationGlobals();
console.log("adaptationGlobals =", adaptationGlobals);

Return

object: adaptation globals as a JSON object

{
  "custom1": "",
  "custom2": "",
  "custom3": "",
  "interactive": "interactive",
  "language": "",
  "layout": "landscape",
  "screenSize": "small",
  "textDirection": "ltr"
}

See also

getCompositionById

Returns the composition object requested by its ID.

Parameters

Name
Type
Description

compositionId

String

The ID of a composition.

const compositionId = "dbc46c1a-1375-4c2c-9f0d-1df5a86d0baf";
const compositionObject = overlay.getComposition(compositionId);
console.log("compositionObject =", compositionObject);

Return

object: Composition object

compositionObject:
> find: Æ’ ()
> getCompositionById: Æ’ (subCompId)
> getControlNode: Æ’ ()
> getDataNodes: Æ’ ()
> getLogicLayer: Æ’ ()
> getModel: Æ’ ()
> getPayload: Æ’ ()
> getPayload2: Æ’ ()
> getState: Æ’ ()
> getSubcompositionById: Æ’ (subCompId)
> id: "dbc46c1a-1375-4c2c-9f0d-1df5a86d0baf"
> jumpTo: Æ’ (to)
> listSubcompositions: Æ’ ()
> playTo: Æ’ (to)
> seek: Æ’ (to)
> sendMessage: Æ’ (message)
> setPayload: Æ’ (_payload)

See also

getCompositionInfo

Returns the JSON definition of the loaded composition.

const compositionInfo = overlay.getCompositionInfo();
console.log("compositionInfo =", compositionInfo);

Return

object: Composition object

{
  "adaptationGlobals": {"screenSize": "small", "layout": "landscape", "textDirection": "ltr", "interactive": "interactive", "language": "", …}
  "compositionDuration": {"-N8o2dhQeHQXZ6Emr2I7": {…}, "04234444-4383-4772-9619-ff971119eb5a": {…}, …}
  "compositionId": "-N8o2dhQeHQXZ6Emr2I7"
  "compositionProps": {"logicLayers": {…}, "timeline2Active": {…}, "durations": {…}}
  "compositionStates": {"-Kn25RyfewL29LigHvV1": "Out1", "-KnXXbHZpD6sKVP4iHCD": "Out1", "-Knh0082CSZTy0CXJ_B_": "Out1", …}
  "dataSources": {"-N8o2dhQeHQXZ6Emr2I7": {…}, "04234444-4383-4772-9619-ff971119eb5a": {…}, …}
  "effect": {"-N8o2dhQeHQXZ6Emr2I7": {…}, "04234444-4383-4772-9619-ff971119eb5a": {…}, …}
  "idToName": {"04234444-4383-4772-9619-ff971119eb5a": "Panel Left - Image", "1c895c6d-f17d-400a-8591-0c38298bbb4f": "Fullscreen - Title", …}
  "nameToId": {"Panel Left - Image": "04234444-4383-4772-9619-ff971119eb5a", "Fullscreen - Title": "1c895c6d-f17d-400a-8591-0c38298bbb4f", …}
  "subcompositionNames": {"-N8o2dhQeHQXZ6Emr2I7": {…}, "04234444-4383-4772-9619-ff971119eb5a": {…}, …}
}

getConfig

Returns the configuration of the overlay.

const config = overlay.getConfig();
console.log("config =", config);

Return

object: JSON object

getMainComposition

Returns the composition object of the main or root composition.

const compMain = overlay.getMainComposition();
console.log("compMain =", compMain);

Return

object: Composition object

compMain:
> find: Æ’ ()
> getCompositionById: Æ’ (subCompId)
> getControlNode: Æ’ ()
> getDataNodes: Æ’ ()
> getLogicLayer: Æ’ ()
> getModel: Æ’ ()
> getPayload: Æ’ ()
> getPayload2: Æ’ ()
> getState: Æ’ ()
> getSubcompositionById: Æ’ (subCompId)
> id: "-N8o2dhQeHQXZ6Emr2I7"
> jumpTo: Æ’ (to)
> listSubcompositions: Æ’ ()
> playTo: Æ’ (to)
> seek: Æ’ (to)
> sendMessage: Æ’ (message)
> setPayload: Æ’ (_payload)

See also

getSequencer

Returns the sequencer object of the overlay.

const sequencer = overlay.getSequencer();
console.log("sequencer =", sequencer);

Return

object: Sequencer object

sequencer:
> play: Æ’ (time)
> seek: Æ’ (time)
> seqId: "-N8o2dhQeHQXZ6Emr2I7"
> setDuration: Æ’ (duration)
> setPayload: Æ’ (payload)
> start: Æ’ ()
> stop: Æ’ ()

See also

loadComposition

Loads a composition into an overlay instance.

overlay.loadComposition(composition, outputName, callback);
Attributes
Type
Required
Description

composition

String

Yes

A composition referenced by token or URL.

outputName

String

Yes

Depreciated. Set output name to null for compatibility reasons.

callback

Function

Yes

Callback function called when the content has been loaded.

Sample

const compositionUrl = "https://assets.singular.live/f12f184c9a0eb763beb40478e02a1250/jsons/164gBjjETnHFKEU3LjPCKe.json";

overlay.loadComposition(compositionUrl, null, (success) => {
  // called when content finished loading
  if (success) {
    console.log("Composition loaded");
  } else {
    console.warn("Couldn't load composition");
  }
});
const compositionToken = "08EBsfeF4yoYLejOXM51Rk";

overlay.loadComposition(compositionToken , null, (success) => {
  // called when content finished loading
  if (success) {
    console.log("Composition loaded");
  } else {
    console.warn("Couldn't load composition");
  }
});

noTrack

Deactivates analytic tracking.

onmessage

This call has been depreciated.

removeAllListener

Removes all registered listeners.

overlay.removeAllListener();

See also

removeListener

Removes a listener specified by its type.

overlay.removeListener(type, callback);
Attributes
Type
Required
Description

type

String

Yes

A string containing one of the values described below.

callback

Function

Yes

The callback function for the type of event.

Values for listener type

Setting
Description

payload_changed

Listens to messages from control node updates.

datanode_payload_changed

Listens to messages from data node updates.

state_changed

Listens to messages for animation state changes.

message

Listens to messages from the interactive events and widgets.

error

Listens to errors reported by an overlay instance.

See also:

renderAppOutput

Load san app output into the overlay instance.

overlay.renderAppOutput(appInstanceId, outputName, callback);
Attributes
Type
Required
Description

appInstanceId

String

Yes

The ID of an app instance.

outputName

String

Yes

Depreciated. Sets output name to null for compatibility reasons.

callback

Function

Yes

The callback function called when the content has been loaded.

Sample

const appInstanceId = 12345;

overlay.renderAppOutput(appInstanceId, null, (success) => {
  // called when content finished loading
  if (success) {
    console.log("App output loaded");
  } else {
    console.warn("Couldn't load app output");
  }
});

renderComposition

Loads a composition into an overlay instance.

overlay.renderComposition(composition, callback);
Attributes
Type
Required
Description

composition

Object

Yes

A composition's JSON object.

callback

Function

Yes

The callback function called when the content has been loaded.

Sample

const composition = {...};

overlay.renderComposition(composition, null, (success) => {
  // called when content finished loading
  if (success) {
    console.log("Composition loaded");
  } else {
    console.warn("Couldn't load composition");
  }
});

setAdaptationGlobals

Sets adaptation global settings.

const adaptationGlobals = {
  "custom1": "stationId=abc123",a
  "custom2": "",
  "custom3": "",
  "interactive": "",
  "language": "",
  "layout": "portrait",
  "screenSize": "small",
  "textDirection": "ltr"
};

overlay.setAdaptationGlobals(adaptationGlobals);

See also

setConfig

Sets the configuration of an overlay.

const config = {...};
overlay.setConfig(config);

setFrameNumber

This call has been depreciated.

videoCommand

This call has been depreciated.

PreviousReferenceNextComposition object

Last updated 2 years ago

Was this helpful?

removeAllListener
removeListener
setAdaptationGlobals
Composition object
Composition object
Sequencer object
addListener
removeListener
removeAllListener
removeListener
getAdaptationGlobals
addListener(event, callback)
getAdaptationGlobals()
getCompositionById(compId)
getCompositionInfo()
getConfig()
getMainComposition()
getSequencer()
loadComposition(compositionId, callback)
noTrack()
onmessage(event)
removeAllListener()
removeListener(event, callback)
renderAppOutput(appId, output, callback)
renderComposition(compositionObject, callback)
setAdaptationGlobals(data)
setConfig(data)
setFrameNumber(frame)
videoCommand(cmd, time)