SingularGraphics(domElement)
Use the following code to create an instance of a Singular overlay:
const overlay = SingularGraphics("SingularOverlay");
Attributes | Type | Required | Description |
---|
| | | |
SDK properties
Name | Type | Example | Description |
---|
| | | |
| | | |
const compMain = overlay.getMainComposition();
console.log("compMain =", compMain);
Return
object
: Graphic SDK object
> 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.
addListener
Adds a listener for events coming from the overlay.
overlay.addListener(type, callback);
Values for listener type
See also:
removeAllListener removeListener
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
{
"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
{
"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
{
"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
{
"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
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
setAdaptationGlobals
getCompositionById
Returns the composition object requested by its ID.
Parameters
const compositionId = "dbc46c1a-1375-4c2c-9f0d-1df5a86d0baf";
const compositionObject = overlay.getComposition(compositionId);
console.log("compositionObject =", compositionObject);
Return
object
: Composition object
> 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
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
> 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
Composition object
getSequencer
Returns the sequencer object of the overlay.
const sequencer = overlay.getSequencer();
console.log("sequencer =", sequencer);
Return
object
: Sequencer object
> play: ƒ (time)
> seek: ƒ (time)
> seqId: "-N8o2dhQeHQXZ6Emr2I7"
> setDuration: ƒ (duration)
> setPayload: ƒ (payload)
> start: ƒ ()
> stop: ƒ ()
See also
Sequencer object
loadComposition
Loads a composition into an overlay instance.
overlay.loadComposition(composition, outputName, callback);
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
addListener
removeListener
removeListener
Removes a listener specified by its type.
overlay.removeListener(type, callback);
Values for listener type
See also:
removeAllListener
removeListener
renderAppOutput
Load san app output into the overlay instance.
overlay.renderAppOutput(appInstanceId, outputName, callback);
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);
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
getAdaptationGlobals
setConfig
Sets the configuration of an overlay.
const config = {...};
overlay.setConfig(config);
This call has been depreciated.
videoCommand
This call has been depreciated.