WebViewer Video allows you to create annotations in a video file and attach them to a specific timeframe. Try it out in our Video Annotation Demo now. It leverages some of the familiar WebViewer annotation tools like Note, Free Text, Rectangle and Free Hand. Video annotations comes out of the box with zero configuration.
It is also possible to control the amount of time said annotation will be displayed on video playback. After the annotation is created, click on the desired annotation on top of the timeline reel and use the directional arrows to expand or contract the amount of time it will be displayed.
Annotations can also have comments attached to it, initially ordered by timeframe (bottom being the earliest to show on video). Those are searchable and can be further sorted by position, time, status, author, type and timecode.
A common use case is to save and retrieve the annotations. Just like on WebViewer, this data is stored in the format of a XFDF string that can be exported using the AnnotationsManager's exportAnnotations API.
One example is to have a custom save button added to the WebViewer's header using the setHeaderItems API that triggers a call to exportAnnotations and sending a POST request to your server to store it.
Assuming that there is a previously setup server running and a POST endpoint that accepts a body containing the XFDF string, you can achieve with the following code snippet:
JavaScript
1// setHeaderItems is a function that can be extracted from a WebViewer instance
2setHeaderItems((header) => {
3 header.push({
4 type: "actionButton",
5 img: "<svg>...</svg>",
6 onClick: async () => {
7 // Save annotations when button is clicked
8 // widgets and links will remain in the document without changing so it isn't necessary to export them
28 var xfdfString = await annotManager.exportAnnotations({
29 links: false,
30 widgets: false,
31 annotList: annotations,
32 });
33
34 // Step 3: Call your endpoint and save it
35 await saveXfdfString(DOCUMENT_ID, xfdfString);
36 alert("Annotations saved successfully.");
37 },
38 });
39});
To load the annotations, the process is quite similar. It involves making a GET request to your server to retrieve the XFDF string, use the AnnotationManager's importAnnotations and finally call video.updateAnnotationsToTime(0) to apply the annotations to the specific timeframes that they were created.
These calls need to be done after the video has been loaded. You can safely do these steps inside docViewer's videoElementLoaded event like the following code snippet example: