Skip to main content

Subscribe to Clip’s events

Hosted Clips provide the subscribe method so via a pub/sub system you can listen to Clip’s millisecond and state changes.

There are the states that a Clip can be found:

  • idle: the Clip has not started execution yet or it has completed execution
  • playing: the Clip is currently been executed
  • paused: the Clip is currently paused
  • transitioning: the Clip is currently been transitioning via TimeCapsule
  • armed: If a Clip starts transitioning while on paused state on seek end it enters the armed state
  • blocked: blocked state indicates that one or more Incidents are still loading and are unable to progress

The subscribe method of hosted Clips accept four arguments

  • id: the id of your subscription. You can use it to unsubscribe from Clip’s events by method unsubscribe which accepts just one argument, your subscription id
  • funct: a function callback that will be called whenever a change on the millisecond or state of the Clip occurs. It accepts two arguments:
    • The current Clip’s millisecond
    • The Clip’s state
  • Threshold (optional): you can set the threshold of milliseconds delta that you want to get notified for. For example if you set threshold to 50 your callback function will only be executed whenever the milliseconds difference between the current millisecond of the Clip and the millisecond you got informed for on the previous callback invocation is greater than 50 milliseconds
  • roundTo (optional): if any of the subscribers want the Scene to provide back a rounded number of the Clip’s milliseconds they can set it here
    • 1 (round it on its actual units
    • 10 (round it on tenths)
    • 100 (round it on hundreds)
    • 1000 (round it on thousands)