summaryrefslogtreecommitdiff
path: root/apps/web/src/timeline/creation.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/timeline/creation.ts')
-rw-r--r--apps/web/src/timeline/creation.ts23
1 files changed, 10 insertions, 13 deletions
diff --git a/apps/web/src/timeline/creation.ts b/apps/web/src/timeline/creation.ts
index 2dec3186..0f28af56 100644
--- a/apps/web/src/timeline/creation.ts
+++ b/apps/web/src/timeline/creation.ts
@@ -1,20 +1,17 @@
-import { TICKS_PER_SECOND } from "@/wasm/ticks";
+import { mediaTime, mediaTimeFromSeconds, TICKS_PER_SECOND } from "@/wasm";
-export const DEFAULT_NEW_ELEMENT_DURATION = 5 * TICKS_PER_SECOND;
+export const DEFAULT_NEW_ELEMENT_DURATION = mediaTime({
+ ticks: 5 * TICKS_PER_SECOND,
+});
-/**
- * Resolves the duration in ticks that a newly created timeline element
- * should have, given an optional source duration in seconds.
- *
- * Falls back to {@link DEFAULT_NEW_ELEMENT_DURATION} when the source has
- * no known duration (e.g. stickers, graphics, text, or media whose
- * probe failed).
- */
export function toElementDurationTicks({
seconds,
}: {
seconds: number | null | undefined;
-}): number {
- if (seconds == null) return DEFAULT_NEW_ELEMENT_DURATION;
- return Math.round(seconds * TICKS_PER_SECOND);
+}) {
+ if (seconds == null) {
+ return DEFAULT_NEW_ELEMENT_DURATION;
+ }
+
+ return mediaTimeFromSeconds({ seconds });
}