diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-07 15:51:53 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-13 05:01:51 +0200 |
| commit | f06a930fc1920b7eb396202d429c237ff30c6b5e (patch) | |
| tree | acc2aceac282570d02a04b601ea303fc832d5f79 /apps/web/src/hooks/use-paste-media.ts | |
| parent | 532f050a647d8d667b8cc2c13b816736c1bf9ec6 (diff) | |
| download | opencut-f06a930fc1920b7eb396202d429c237ff30c6b5e.tar.gz | |
fix: convert media asset duration to ticks on insert
Diffstat (limited to 'apps/web/src/hooks/use-paste-media.ts')
| -rw-r--r-- | apps/web/src/hooks/use-paste-media.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/apps/web/src/hooks/use-paste-media.ts b/apps/web/src/hooks/use-paste-media.ts index 36d70ebe..ca821d6b 100644 --- a/apps/web/src/hooks/use-paste-media.ts +++ b/apps/web/src/hooks/use-paste-media.ts @@ -8,6 +8,7 @@ import { AddMediaAssetCommand } from "@/lib/commands/media"; import { InsertElementCommand } from "@/lib/commands/timeline"; import { BatchCommand } from "@/lib/commands"; import { DEFAULT_NEW_ELEMENT_DURATION } from "@/lib/timeline/creation"; +import { TICKS_PER_SECOND } from "@/lib/wasm"; import { isTypableDOMElement } from "@/utils/browser"; import type { MediaType } from "@/lib/media/types"; @@ -73,8 +74,10 @@ export function usePasteMedia() { asset, ); const assetId = addMediaCmd.getAssetId(); - const duration = - asset.duration ?? DEFAULT_NEW_ELEMENT_DURATION; + const duration = + asset.duration != null + ? Math.round(asset.duration * TICKS_PER_SECOND) + : DEFAULT_NEW_ELEMENT_DURATION; const trackType = asset.type === "audio" ? "audio" : "video"; const element = buildElementFromMedia({ |
