summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-03-31 23:24:33 +0200
committerMaze Winther <mazewinther@gmail.com>2026-03-31 23:24:33 +0200
commit608dc1a62fdb133e218f45796cf936bdfb27c7ae (patch)
tree605132265bab1f345b0edfee8bdadfcaf8e973db /apps/web/src/hooks
parentcc150c7cfb859dfc38372210ec5bcc8bd196bbc4 (diff)
parentf1d5932c54178c4f8eac61d3d3e0e4a30101780f (diff)
downloadopencut-608dc1a62fdb133e218f45796cf936bdfb27c7ae.tar.gz
Merge branch 'feature/separate-audio'
Diffstat (limited to 'apps/web/src/hooks')
-rw-r--r--apps/web/src/hooks/actions/use-editor-actions.ts48
1 files changed, 47 insertions, 1 deletions
diff --git a/apps/web/src/hooks/actions/use-editor-actions.ts b/apps/web/src/hooks/actions/use-editor-actions.ts
index ba480a30..87aa6b48 100644
--- a/apps/web/src/hooks/actions/use-editor-actions.ts
+++ b/apps/web/src/hooks/actions/use-editor-actions.ts
@@ -6,9 +6,13 @@ import { useActionHandler } from "@/hooks/actions/use-action-handler";
import { useEditor } from "../use-editor";
import { useElementSelection } from "../timeline/element/use-element-selection";
import { useKeyframeSelection } from "../timeline/element/use-keyframe-selection";
-import { getElementsAtTime } from "@/lib/timeline";
+import {
+ getElementsAtTime,
+ hasMediaId,
+} from "@/lib/timeline";
import { cancelInteraction } from "@/lib/cancel-interaction";
import { invokeAction } from "@/lib/actions";
+import { canToggleSourceAudio } from "@/lib/timeline/audio-separation";
import {
activateScope,
clearActiveScope,
@@ -266,6 +270,48 @@ export function useEditorActions() {
);
useActionHandler(
+ "toggle-source-audio",
+ () => {
+ if (selectedElements.length !== 1) {
+ return;
+ }
+
+ const selectedElement = editor.timeline.getElementsWithTracks({
+ elements: selectedElements,
+ })[0];
+ if (!selectedElement) {
+ return;
+ }
+
+ const mediaAsset = (() => {
+ const { element } = selectedElement;
+ if (!hasMediaId(element)) {
+ return null;
+ }
+
+ return (
+ editor.media.getAssets().find((asset) => asset.id === element.mediaId) ??
+ null
+ );
+ })();
+ if (
+ !canToggleSourceAudio({
+ element: selectedElement.element,
+ mediaAsset,
+ })
+ ) {
+ return;
+ }
+
+ editor.timeline.toggleSourceAudioSeparation({
+ trackId: selectedElement.track.id,
+ elementId: selectedElement.element.id,
+ });
+ },
+ undefined,
+ );
+
+ useActionHandler(
"select-all",
() => {
const allElements = editor.timeline.getTracks().flatMap((track) =>