WeaveVideoToolAction
Add a video to the canvas
Overview
The WeaveVideoToolAction class that enables users to insert video nodes into the canvas. It provides an intuitive way to add visual content—either by selecting a video file, dragging and dropping, or integrating with an video picker—allowing users to enhance their collaborative workspace with rich media.
Each interaction results in the creation of a WeaveVideoNode, which can be resized, moved, and synchronized across all connected users.
The class extends the WeaveAction class.
Name
This action name property value is videoTool.
Import
import { WeaveVideoToolAction } from "@inditextech/weave-sdk";Instantiation
new WeaveVideoToolAction();TypeScript types
type WeaveVideoToolActionStateKeys = keyof typeof VIDEO_TOOL_STATE;
type WeaveVideoToolActionState =
(typeof VIDEO_TOOL_STATE)[WeaveVideoToolActionStateKeys];
type WeaveVideoToolDragParams = {
placeholderUrl: string;
url: string;
width: number;
height: number;
};
type WeaveVideoToolActionTriggerParams = {
videoId?: string;
videoParams?: WeaveVideoToolDragParams;
position?: Vector2d;
forceMainContainer?: boolean;
};
type WeaveVideoToolActionTriggerReturn =
| {
finishUploadCallback: (
videoParams: WeaveVideoToolDragParams,
position?: Vector2d,
) => void;
}
| undefined;
type WeaveVideoToolActionOnAddingEvent = { videoURL: string };
type WeaveVideoToolActionOnAddedEvent = {
videoURL: string;
nodeId: string;
};Trigger function params
trigger(cancelAction: () => void, params?: WeaveVideoToolActionTriggerParams): WeaveVideoToolActionTriggerReturnFor WeaveVideoToolActionTriggerParams:
| Prop | Type | Default |
|---|---|---|
forceMainContainer? | boolean | - |
position? | Vector2d | - |
videoParams? | WeaveVideoToolDragParams | - |
videoId? | string | - |
Drag & Drop from the same application
When you implement drag & drop of a video loaded on a HTMLVideoElement that is located on the same application,
on the onDragStart event you must call the setDragAndDropProperties method of the tool and define the following
properties:
videoId: the video id (external resource id) associated to the image.videoParams: the video parameters: video placeholder URL, video URL, video width and video height
Events
onAddingVideo
onAddingVideo: WeaveNodesSelectionPluginOnNodesChangeEvent;The onAddingVideo event is called when the tool is ready to add a video.
onAddedVideo
onAddedVideo: WeaveVideoToolActionOnAddedEvent;The onAddedVideo event is called when the video has been added to the canvas.
Methods
setDragAndDropProperties
setDragAndDropProperties(properties: WeaveVideoToolDragAndDropProperties): voidThe setDragAndDropProperties method set the necessary properties when drag & drop videos that are inside the application.
