Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions immichFrame.Web/src/lib/components/elements/asset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { thumbHashToDataURL } from 'thumbhash';
import AssetInfo from '$lib/components/elements/asset-info.svelte';
import ImageOverlay from '$lib/components/elements/imageoverlay/image-overlay.svelte';
import { onDestroy } from 'svelte';

interface Props {
asset: [url: string, asset: AssetResponseDto, albums: AlbumResponseDto[]];
Expand Down Expand Up @@ -184,6 +185,18 @@
}
}
};

let isDestroyed = false;

onDestroy(() => {
isDestroyed = true;
if (videoElement) {
videoElement.pause();
videoElement.src = '';
videoElement.removeAttribute('src');
videoElement.load();
}
});
</script>

{#if showInfo}
Expand Down Expand Up @@ -246,9 +259,12 @@
}
}
}}
onerror={() => console.error('Video failed to load:', asset[0])}
onwaiting={onVideoWaiting}
onplaying={onVideoPlaying}
onwaiting={() => {
if (!isDestroyed) onVideoWaiting();
}}
onplaying={() => {
if (!isDestroyed) onVideoPlaying();
}}
></video>
{:else}
<img
Expand Down
34 changes: 17 additions & 17 deletions immichFrame.Web/src/lib/components/home-page/home-page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,24 @@
}
}

let isHandlingAssetTransition = false;
let transitionLock: Promise<void> = Promise.resolve();

const handleDone = async (previous: boolean = false, instant: boolean = false) => {
if (isHandlingAssetTransition) {
return;
}
isHandlingAssetTransition = true;
try {
userPaused = false;
progressBar.restart(false);
$instantTransition = instant;
if (previous) await getPreviousAssets();
else await getNextAssets();
await tick();
await assetComponent?.play?.();
progressBar.play();
} finally {
isHandlingAssetTransition = false;
}
transitionLock = transitionLock
.then(async () => {
userPaused = false;
progressBar.restart(false);
$instantTransition = instant;
if (previous) await getPreviousAssets();
else await getNextAssets();
await tick();
await assetComponent?.play?.();
progressBar.play();
})
.catch((err) => {
console.error('handleDone transition failed:', err);
});
await transitionLock;
};

async function getNextAssets() {
Expand Down
Loading