@twick/video-editor 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/dist/hooks/use-player-manager.d.ts +2 -0
- package/dist/index.js +34 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -11
- package/dist/index.mjs.map +1 -1
- package/dist/video-editor.css +493 -470
- package/package.json +13 -13
- package/LICENSE +0 -197
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# @twick/video-editor
|
|
2
|
-
|
|
3
|
-
A React component for video editing and timeline management
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🎥 Video preview with custom controls
|
|
8
|
-
- ⏱️ Timeline-based editing interface
|
|
9
|
-
- 📊 Multi-track timeline support
|
|
10
|
-
- 🎯 Customizable video dimensions
|
|
11
|
-
- 🔄 Drag-and-drop timeline reordering
|
|
12
|
-
- ⚡ High-performance video rendering
|
|
13
|
-
|
|
14
|
-
## Requirements
|
|
15
|
-
|
|
16
|
-
- React 18 or higher
|
|
17
|
-
- Browser environment with HTML5 Video support
|
|
18
|
-
|
|
1
|
+
# @twick/video-editor
|
|
2
|
+
|
|
3
|
+
A React component for video editing and timeline management
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎥 Video preview with custom controls
|
|
8
|
+
- ⏱️ Timeline-based editing interface
|
|
9
|
+
- 📊 Multi-track timeline support
|
|
10
|
+
- 🎯 Customizable video dimensions
|
|
11
|
+
- 🔄 Drag-and-drop timeline reordering
|
|
12
|
+
- ⚡ High-performance video rendering
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- React 18 or higher
|
|
17
|
+
- Browser environment with HTML5 Video support
|
|
18
|
+
|
|
19
19
|
## Installation
|
package/dist/index.js
CHANGED
|
@@ -7779,6 +7779,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7779
7779
|
}) => {
|
|
7780
7780
|
const [projectData, setProjectData] = React.useState(null);
|
|
7781
7781
|
const { timelineAction, setTimelineAction, setSelectedItem, editor } = timeline.useTimelineContext();
|
|
7782
|
+
const [playerUpdating, setPlayerUpdating] = React.useState(false);
|
|
7782
7783
|
const handleCanvasReady = (canvas) => {
|
|
7783
7784
|
console.log("canvas ready", canvas);
|
|
7784
7785
|
};
|
|
@@ -7812,12 +7813,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7812
7813
|
cleanAndAdd: true
|
|
7813
7814
|
});
|
|
7814
7815
|
};
|
|
7816
|
+
const onPlayerUpdate = (event) => {
|
|
7817
|
+
var _a2;
|
|
7818
|
+
if (((_a2 = event == null ? void 0 : event.detail) == null ? void 0 : _a2.status) === "ready") {
|
|
7819
|
+
setPlayerUpdating(false);
|
|
7820
|
+
setTimelineAction(timeline.TIMELINE_ACTION.ON_PLAYER_UPDATED, null);
|
|
7821
|
+
}
|
|
7822
|
+
};
|
|
7815
7823
|
React.useEffect(() => {
|
|
7816
7824
|
var _a2, _b, _c, _d;
|
|
7817
7825
|
switch (timelineAction.type) {
|
|
7818
7826
|
case timeline.TIMELINE_ACTION.UPDATE_PLAYER_DATA:
|
|
7819
7827
|
if (videoProps) {
|
|
7820
7828
|
if (((_a2 = timelineAction.payload) == null ? void 0 : _a2.forceUpdate) || editor.getLatestVersion() !== ((_b = projectData == null ? void 0 : projectData.input) == null ? void 0 : _b.version)) {
|
|
7829
|
+
setPlayerUpdating(true);
|
|
7821
7830
|
const _latestProjectData = {
|
|
7822
7831
|
input: {
|
|
7823
7832
|
properties: videoProps,
|
|
@@ -7826,9 +7835,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7826
7835
|
}
|
|
7827
7836
|
};
|
|
7828
7837
|
setProjectData(_latestProjectData);
|
|
7838
|
+
} else {
|
|
7839
|
+
setTimelineAction(timeline.TIMELINE_ACTION.ON_PLAYER_UPDATED, null);
|
|
7829
7840
|
}
|
|
7830
7841
|
}
|
|
7831
|
-
setTimelineAction(timeline.TIMELINE_ACTION.ON_PLAYER_UPDATED, null);
|
|
7832
7842
|
break;
|
|
7833
7843
|
}
|
|
7834
7844
|
}, [timelineAction]);
|
|
@@ -7836,7 +7846,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7836
7846
|
twickCanvas,
|
|
7837
7847
|
projectData,
|
|
7838
7848
|
updateCanvas,
|
|
7839
|
-
buildCanvas
|
|
7849
|
+
buildCanvas,
|
|
7850
|
+
onPlayerUpdate,
|
|
7851
|
+
playerUpdating
|
|
7840
7852
|
};
|
|
7841
7853
|
};
|
|
7842
7854
|
const PlayerManager = ({
|
|
@@ -7844,7 +7856,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7844
7856
|
canvasMode
|
|
7845
7857
|
}) => {
|
|
7846
7858
|
const { changeLog } = timeline.useTimelineContext();
|
|
7847
|
-
const { twickCanvas, projectData, updateCanvas, buildCanvas } = usePlayerManager({ videoProps });
|
|
7859
|
+
const { twickCanvas, projectData, updateCanvas, playerUpdating, onPlayerUpdate, buildCanvas } = usePlayerManager({ videoProps });
|
|
7848
7860
|
const durationRef = React.useRef(0);
|
|
7849
7861
|
const {
|
|
7850
7862
|
playerState,
|
|
@@ -7876,7 +7888,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7876
7888
|
}
|
|
7877
7889
|
}, [twickCanvas, playerState, seekTime, changeLog]);
|
|
7878
7890
|
const handleTimeUpdate = (time2) => {
|
|
7879
|
-
if (time2 >= durationRef.current) {
|
|
7891
|
+
if (durationRef.current && time2 >= durationRef.current) {
|
|
7880
7892
|
setCurrentTime(0);
|
|
7881
7893
|
setPlayerState(livePlayer.PLAYER_STATE.PAUSED);
|
|
7882
7894
|
} else {
|
|
@@ -7891,6 +7903,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7891
7903
|
aspectRatio: `${videoProps.width}/${videoProps.height}`
|
|
7892
7904
|
},
|
|
7893
7905
|
children: [
|
|
7906
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7907
|
+
"div",
|
|
7908
|
+
{
|
|
7909
|
+
className: "twick-editor-loading-overlay",
|
|
7910
|
+
style: {
|
|
7911
|
+
opacity: playerUpdating ? 1 : 0
|
|
7912
|
+
},
|
|
7913
|
+
children: playerUpdating ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "twick-editor-loading-spinner" }) : null
|
|
7914
|
+
}
|
|
7915
|
+
),
|
|
7894
7916
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7895
7917
|
livePlayer.LivePlayer,
|
|
7896
7918
|
{
|
|
@@ -7900,6 +7922,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
7900
7922
|
width: videoProps.width,
|
|
7901
7923
|
height: videoProps.height
|
|
7902
7924
|
},
|
|
7925
|
+
onPlayerUpdate,
|
|
7903
7926
|
containerStyle: {
|
|
7904
7927
|
opacity: canvasMode ? playerState === livePlayer.PLAYER_STATE.PAUSED ? 0 : 1 : 1
|
|
7905
7928
|
},
|
|
@@ -17392,11 +17415,11 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17392
17415
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17393
17416
|
"button",
|
|
17394
17417
|
{
|
|
17395
|
-
className: `control-btn play-pause-btn player-controls-play-pause-btn${playerState === livePlayer.PLAYER_STATE.PLAYING ? " playing" : ""}${playerState === livePlayer.PLAYER_STATE.
|
|
17418
|
+
className: `control-btn play-pause-btn player-controls-play-pause-btn${playerState === livePlayer.PLAYER_STATE.PLAYING ? " playing" : ""}${playerState === livePlayer.PLAYER_STATE.REFRESH ? " refreshing" : ""}`,
|
|
17396
17419
|
onClick: togglePlayback,
|
|
17397
|
-
title: playerState === livePlayer.PLAYER_STATE.PLAYING ? "Pause" : playerState === livePlayer.PLAYER_STATE.
|
|
17398
|
-
disabled: playerState === livePlayer.PLAYER_STATE.
|
|
17399
|
-
children: playerState === livePlayer.PLAYER_STATE.PLAYING ? /* @__PURE__ */ jsxRuntime.jsx(Pause, { size: 28, strokeWidth: 2 }) : playerState === livePlayer.PLAYER_STATE.
|
|
17420
|
+
title: playerState === livePlayer.PLAYER_STATE.PLAYING ? "Pause" : playerState === livePlayer.PLAYER_STATE.REFRESH ? "Refreshing" : "Play",
|
|
17421
|
+
disabled: playerState === livePlayer.PLAYER_STATE.REFRESH,
|
|
17422
|
+
children: playerState === livePlayer.PLAYER_STATE.PLAYING ? /* @__PURE__ */ jsxRuntime.jsx(Pause, { size: 28, strokeWidth: 2 }) : playerState === livePlayer.PLAYER_STATE.REFRESH ? /* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { size: 28, strokeWidth: 2, className: "refreshing-spinner" }) : /* @__PURE__ */ jsxRuntime.jsx(Play, { size: 28, strokeWidth: 2 })
|
|
17400
17423
|
}
|
|
17401
17424
|
),
|
|
17402
17425
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "time-display player-controls-time-display", children: [
|
|
@@ -17418,14 +17441,14 @@ This message will only show in development mode. It won't appear in production.
|
|
|
17418
17441
|
playerStateRef.current = livePlayer.PLAYER_STATE.PAUSED;
|
|
17419
17442
|
setPlayerState(livePlayer.PLAYER_STATE.PAUSED);
|
|
17420
17443
|
} else if (playerState === livePlayer.PLAYER_STATE.PAUSED) {
|
|
17421
|
-
playerStateRef.current = livePlayer.PLAYER_STATE.
|
|
17422
|
-
setPlayerState(livePlayer.PLAYER_STATE.
|
|
17444
|
+
playerStateRef.current = livePlayer.PLAYER_STATE.REFRESH;
|
|
17445
|
+
setPlayerState(livePlayer.PLAYER_STATE.REFRESH);
|
|
17423
17446
|
setTimelineAction(timeline.TIMELINE_ACTION.UPDATE_PLAYER_DATA, present);
|
|
17424
17447
|
}
|
|
17425
17448
|
};
|
|
17426
17449
|
React.useEffect(() => {
|
|
17427
17450
|
if (timelineAction.type === timeline.TIMELINE_ACTION.ON_PLAYER_UPDATED) {
|
|
17428
|
-
if (playerStateRef.current === livePlayer.PLAYER_STATE.
|
|
17451
|
+
if (playerStateRef.current === livePlayer.PLAYER_STATE.REFRESH) {
|
|
17429
17452
|
playerStateRef.current = livePlayer.PLAYER_STATE.PLAYING;
|
|
17430
17453
|
setPlayerState(livePlayer.PLAYER_STATE.PLAYING);
|
|
17431
17454
|
}
|