Sync Engine API

Sync Engine Events and Methods for JS Decoder



Each of the Sync Engines supported by Intrasonics JS Decoder can be accessed via a property on the global intrasonics object. This object becomes available when including intrasonics.js.

The Event Engine variant is referenced using intrasonics.eventEngine and Heartbeat Engine is referenced using intrasonics.heartbeatEngine such that methods can be called on individual engines e.g. intrasonics.eventEngine.getCurrentSyncTime().

Both Sync Engines support the following public events and methods.




Sync Engine Events


Please refer to the Javascript API documentation for information on how to implement event listeners in code so your web application can respond. Below is the list of additional events raised when a Sync Engine is active.


Event Payload Description
"desync"
{ 
  id: String,
  engine: String,
  timestamp: String,
  engineTime: Integer
}
Emitted when the JS Decoder, after being synced for a given engine, has not detected a sync marker for a duration specified by syncTimeoutSecs in the currently loaded Event List.

The id property contains the unique content identifier as a string (Track ID for Event Engine, Station ID for Heartbeat Engine).
The engine property identifies which Sync Engine is now sychronised (EVENT_ENGINE or HEARTBEAT_ENGINE).
The timestamp property is when the JS Decoder first detected a sync marker (given as the number of milliseconds since 00:00 on 1st Jan 1970).
The engineTime property is the time offset calculated by the Sync Engine at the point of desynchronisation. For EVENT_ENGINE this value represents the number of milliseconds since the start of encoding (usually the start of the file), and for HEARTBEAT_ENGINE it is the number of milliseconds since 00:00 on 1st January (the start of the current calendar year).
"sync"
{ 
  id: String,
  engine: String,
  timestamp: String,
  engineTime: Integer
}
Emitted when the decoder has processed the first sync codeword and is ready to trigger accurately timed interactions.

The id property contains the unique content identifier as a string (Track ID for Event Engine, Station ID for Heartbeat Engine).
The engine property identifies which Sync Engine is now sychronised (EVENT_ENGINE or HEARTBEAT_ENGINE).
The timestamp property is when the JS Decoder first detected a sync marker (given as the number of milliseconds since 00:00 on 1st Jan 1970). The engineTime property is the time offset detected in the encoding with which the JS Decoder will base timed interactions.
For EVENT_ENGINE this value represents the number of milliseconds since the start of encoding (usually the start of the file), and for HEARTBEAT_ENGINE it is the number of milliseconds since 00:00 on 1st January (the start of the current calendar year).


Sync Engine Methods


Method Description
clearEventsList(
    schemeName:String
) : void
Clears any timed events registered with JS Decoder for a given schemeName.
getCurrentSyncTime(void) : Integer
Returns the current time offset as calculated by the Sync Engine according to the encoding.

For EVENT_ENGINE this value represents the number of milliseconds since the start of encoding (usually the start of the file), and for HEARTBEAT_ENGINE it is the number of milliseconds since 00:00 on 1st January (the start of the current calendar year).
isSynced(void) : Boolean
Returns whether the JS Decoder has synchronised its timing with the encoding of the content being heard by the microphone.
loadEventsList(
    url:String,
    callback:Function
) : void
Loads a file from a specified url containing an Event List and registers timed events with JS Decoder for the given schemeName.
See the Event List format documentation above for guidance.
setEventsList(
    eventsList:Object
) : void
Registers timed events specified in eventsList with JS Decoder for the given schemeName.
See the Event List format documentation above.