Composition object

Properties

NameTypeExampleDescription

id

String

"303798-latest-1589207585405"

The ID of the composition.

Methods

The composition object has following methods:

MethodReturn typeBrief description

Object

Returns the composition object of a sub-composition with a specified name.

Object

Returns the composition object of a sub-composition with a specified id.

Object

Returns a composition's control nodes.

getDataNode()

Object

Returns a composition's data nodes.

Object

Returns a composition's logic layers.

Object

Returns a composition's model description.

Object

Returns a composition's payload as an array.

Object

Returns a composition's payload as a JSON object.

Object

Returns a composition's state.

Object

Returns the composition object of a sub-composition with a specified id.

-

Jumps to the animation state specified by to.

Object

Returns an array of a composition's sub-compositions.

-

Plays to the animation state specified by to.

-

Sends a custom message.

-

Sets a composition's payload.

find(name)

Returns an array of composition objects with a specified name.

Parameters

NameTypeDescription

name

String

The name of the composition.

const name = "LowerThird";
// we use the first element in the array
const compObject = composition.find(name)[0];

Return

Array: An array of composition objects

compObject:
> 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

Composition object

getCompositionById(id)

Returns the composition object of a sub-composition with a specified id.

Parameters

NameTypeDescription

id

String

The sub-composition ID.

const id = "dbc46c1a-1375-4c2c-9f0d-1df5a86d0baf";
const compObject = composition.find(id);

Return

object: Composition object

compObject:
> 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

Composition object

getControlNode()

Returns a composition's control node model and payload.

const controlnode = compositionObject.getControlNode();

Return

object: A JSON description, if the composition has control nodes undefined: if the composition doesn't have any control nodes

{
  "id": "controlNode",
  "model": {
    "fields": {
      "3c686562-1cf3-7493-7fae-803009afa22e": {
        "defaultValue": "Default Text",
        "id": "Top Title",
        "index": 2,
        "title": "Top Title",
        "type": "text"
      },
      "502a7d0e-e0f8-a895-1b80-43cdb81a1ca9": {
        "defaultValue": "Default Text",
        "id": "Bottom Title",
        "index": 3,
        "title": "Bottom Title",
        "type": "text"
      }
    }
  },
  "name": "Control Node",
  "payload": {
    "Bottom Title": "Extra Information",
    "Top Title": "SINGULAR.LIVE"
  },
  "thumbnail": "/images/noimage.png"
}

getLogicLayer()

Returns a composition's logic layer details.

const logicLayer = compositionObject.getLogicLayer();

Return

object: a JSON description, if a logic layer has been defined for the composition

undefined: if no logic layer has been defined for the composition

{
  "name": "Lower",
  "tag": "#B0C8CD"
}

getModel()

Returns the model description of a composition's control node fields.

const model = compositionObject.getModel();

Return

object: An array of JSON objects, if the composition has control nodes

undefined: if the composition doesn't have any control nodes

[
  {
    "0": {
      "defaultValue": "Default Text",
      "id": "Top Title",
      "index": 2,
      "title": "Top Title",
      "type": "text"
    }
  },
  {
    "1": {
      "defaultValue": "Default Text",
      "id": "Bottom Title",
      "index": 3,
      "title": "Bottom Title",
      "type": "text"
    }
  }
]

getPayload()

Returns the payload of a composition's control node.

const payload = compositionObject.getPayload();

Return

object: An array of JSON objects, if the composition has control nodes

undefined: if the composition doesn't have any control nodes

[
  {
    "0": {
      "key": "Bottom Title",
      "value": "Extra Information"
    }
  },
  {
    "1": {
      "key": "Top Title",
      "value": "SINGULAR.LIVE"
    }
  }
]

getPayload2()

Returns the control node content from the composition as a JSON object.

const payload = comp.getPayload2();
console.log(payload);

getState()

Returns the composition's animation state.

const animState = compositionObject.getState();

Return

String: animation state

getState = Out

getSubcompositionById(id)

Returns the composition object of a sub-composition with a specified id.

Parameters

NameTypeDescription

id

String

ID of the sub-composition

const id = "dbc46c1a-1375-4c2c-9f0d-1df5a86d0baf";
const compObject = composition.find(id);

Return

object: Composition object

compObject:
> 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

Composition object

jumpTo(to)

Jumps to the animation state specified by to.

compositionObject.jumpTo("In");

Return

none

listSubcompositions()

Returns an array of a composition's sub-compositions.

const subcompositionList = compositionObject.listSubcompositions();

Return

object: An array of JSON objects

[ { "id": "a4db02c8-df43-4737-a43d-ba9a4430cd86", "name": "Lower 1 Line - Large" } ]

playTo(to)

Plays to the animation state specified by to.

compositionObject.playTo("In");

Return

none

sendMessage(message)

Send a message to the composition. Use the message listener to receive the message in the Composition Script.

AttributesTypeRequiredDescription

object

object

Yes

Custom data as JSON object

setPayload(payload)

Sets the payload of a composition's control nodes.

const payload = {
  "Bottom Title": "Extra Information",
  "Top Title": "SINGULAR.LIVE",
};
compositionObject.setPayload(payload);

Return

none

Last updated