Waymark Plugin — Client-side Events
The Waymark Plugin emits a variety of client-side events which you may subscribe to to keep track of changes to the Plugin's state.
Subscribing to events
Events can be subscribed to in 3 different ways:
-
Events can be subscribed to with the
Waymark.on
method.waymark.on('waymarkOpened', () => { console.log('The Waymark AI view has opened successfully'); });
-
Events are also emitted globally on the document where each event's name follows the format
"waymark:<eventName>"
.document.addEventListener('waymark:waymarkOpened', () => { console.log('The Waymark AI view has opened successfully'); });
-
Events can also be subscribed to by passing callbacks to the callbacks option in the Waymark constructor.
const waymark = new Waymark('my-partner-id', { callbacks: { waymarkOpened: () => { console.log('The Waymark AI view has opened successfully'); }, }, });
Event list
The Plugin may emit the following events:
waymarkOpened
type: CustomEvent<undefined>
Emitted when the Waymark AI view has successfully opened.
This will happen when:
- The Waymark AI view has opened after a Waymark.openWaymark call.
- The user has clicked the "Exit" button in the editor to return to the Waymark AI view.
- Note that this is not applicable if the editor was directly opened via Waymark.openEditorForVideo.
waymarkOpenFailed
type: CustomEvent<Error>
Emitted when an error occurred while attempting to open the Waymark AI view with a Waymark.openWaymark call.
The event detail will be an Error
object with details about the error which occurred.
A generic error
event will be emitted along with this event as well.
editorExited
type: CustomEvent<undefined>
Emitted when the user exits the Waymark Editor by either clicking the "Exit" button to close the editor or the "Finish" button to complete the video.
If the user clicked the "Exit" button:
- If the Editor was opened from the Waymark AI view, the Plugin will return back to the Waymark AI view again and a
waymarkOpened
event will also be emitted. - If the Editor was opened directly via Waymark.openEditorForVideo, this means the user has ended their editing session and you should handle that accordingly, likely by calling
Waymark.close()
.
If the user clicked the "Finish" button:
- This event will be emitted following a
videoSaved
event and avideoCompleted
event.
editorOpened
type: CustomEvent<VideoData>
Emitted when the Waymark Editor has successfully opened for a video.
The event detail will be a VideoData
object with details about the video which was opened in the editor.
This event will be emitted both when the Editor was opened directly via waymark.openEditorForVideo, or if the user opens a video in the Editor from the Waymark AI view.
editorOpenFailed
type: CustomEvent<Error>
Emitted when an error has occurred while attempting to open the Waymark Editor.
The event detail will be an Error
object with details about the error which occurred.
This event will be emitted both if an error occurs when attempting to directly open the Editor via waymark.openEditorForVideo, or if an error occurs when the user tries to open a video in the Editor from the Waymark AI view.
A generic error
event will be emitted along with this event as well.
videoCreated
type: CustomEvent<VideoData>
Emitted when the user saves a new video to their account.
The event detail will be a VideoData
object with details about the video which was created.
This event will be emitted when the user clicks the "Edit & Continue" button in the Waymark AI flow to save a new video to their account and open it in the Editor.
videoSaved
Event type: CustomEvent<VideoData>
Emitted when Waymark saves changes to the user's video.
The event detail will be a VideoData
object with details about the video which was saved.
This event will be emitted in the following scenarios:
- When a video is saved for the first time, alongside the
videoCreated
event - When Waymark auto-saves the video as the user makes changes in the editor
- When the user clicks the "Exit" button to close the editor, alongside the
editorExited
event - When the user clicks the "Finish" button to complete their video, alongside the
videoCompleted
event
videoCompleted
type: CustomEvent<VideoData>
Emitted when a user has clicked the "Finish" button to complete their video. Waymark will start rendering the video at this point.
The event detail will be a VideoData
object with details about the video which was completed.
Note that if a user re-opens a video which they have already completed and clicks the "Finish" button again without making any changes, Waymark will not kick off a new render.
videoRendered
type: CustomEvent<VideoData>
Emitted when a video belonging to the user's account finishes rendering.
The event detail will be a VideoData
object with details about the video which rendered.
error
Event type: CustomEvent<Error>
Emitted when any error occurs in the Plugin.
The event detail will be an Error
object with details about the error which occurred.