diff --git a/src/frontend/components/actions/actions.ts b/src/frontend/components/actions/actions.ts index ebc57c5b..45b4d9c9 100644 --- a/src/frontend/components/actions/actions.ts +++ b/src/frontend/components/actions/actions.ts @@ -93,6 +93,10 @@ export function addSlideAction(slideIndex: number, actionId: string, actionValue history({ id: "SHOW_LAYOUT", newData: { key: "actions", data: actions, indexes: [slideIndex] } }) } +export function slideHasAction(actions: any, key: string) { + return actions?.slideActions?.find((a) => a.triggers?.includes(key)) +} + // extra names const namedObjects = { diff --git a/src/frontend/components/drawer/media/MediaLoader.svelte b/src/frontend/components/drawer/media/MediaLoader.svelte index 1636d8f8..39022919 100644 --- a/src/frontend/components/drawer/media/MediaLoader.svelte +++ b/src/frontend/components/drawer/media/MediaLoader.svelte @@ -21,6 +21,7 @@ export let loaded: boolean = false export let resolution: Resolution | null = null export let duration: number = 0 + export let getDuration: boolean = false export let videoElem: any = null $: if (path) loaded = false @@ -39,7 +40,7 @@ $: if (mediaStyle.speed && videoElem) videoElem.playbackRate = mediaStyle.speed $: if (!videoElem) duration = 0 - function getDuration() { + function getCurrentDuration() { if (!videoElem || duration) return duration = videoElem.duration @@ -71,15 +72,17 @@ $: useOriginal = hover || loadFullImage || retryCount > 5 || !thumbnailPath // get duration - $: if (type === "video" && thumbnailPath) getVideoDuration() + $: if (getDuration && type === "video" && thumbnailPath) getVideoDuration() function getVideoDuration() { - let video = document.createElement("video") - video.onloadeddata = () => { - duration = video.duration || 0 - // video.pause() - video.src = "" - } - video.src = path + setTimeout(() => { + let video = document.createElement("video") + video.onloadeddata = () => { + duration = video.duration || 0 + // video.pause() + video.src = "" + } + video.src = path + }, 20) } @@ -109,7 +112,7 @@ {/key} {/if} {#if type === "video" && useOriginal} -