API & Integration -> Preview SDK
Events
onReady, onLoad, onLoadComplete, onPlay, onPause, onTimeChange, onStateChange, onActiveElementsChange, onActiveCompositionChange, onToolChange, onScaleChange
The Preview SDK notifies your app through events: when the engine is ready, when a file finishes buffering, when the user presses play or drags an element.
| Event | Called when, and what for |
|---|---|
onReady() |
The engine has loaded and the preview can be used. Load your first video here; a call before this throws. |
onLoad() |
A file starts downloading or buffering. Show a loading indicator. |
onLoadComplete() |
Loading ends, whether it succeeded or not. Hide the indicator. A failure is reported by the method that needed the file, which rejects its promise. |
onPlay() |
Playback starts, from play() or the built-in play button. Update your play button. |
onPause() |
Playback stops, from pause(), the built-in button, or because the preview pauses to buffer. The last case is why a play button follows this event rather than your own flag. |
onTimeChange(time) |
The playback time changes, in seconds. Move a playhead. |
onStateChange(state) |
The video changes in any way: a load, a modification, or an edit on the canvas. Keep your UI in step with the video, such as the undo buttons and the playhead's length. state is described under State. |
onActiveElementsChange(elementIds) |
The selection changes in interactive mode. Show the selected element's properties. |
onActiveCompositionChange(elementId) |
The user opens another composition for editing; null is the main composition. |
onToolChange(tool) |
The mouse tool changes in interactive mode. Highlight the active tool. |
onScaleChange(scale) |
The canvas is zoomed; 1 is 100%. Show the zoom level. |
Errors are not reported through a separate event. Instead, they are thrown by the function that caused them, as explained under Loading and changing content.
Next step
What onStateChange hands you, and why your app needs it: State.