mirror of
https://github.com/LukeHagar/immich.git
synced 2025-12-10 12:37:46 +00:00
* refactor: asset media endpoints * refactor: mobile upload livePhoto as separate request * refactor: change mobile backup flow to use new asset upload endpoints * chore: format and analyze dart code * feat: mark motion as hidden when linked * feat: upload video portion of live photo before image portion * fix: incorrect assetApi calls in mobile code * fix: download asset --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Zack Pollard <zackpollard@ymail.com>
69 lines
2.0 KiB
Svelte
69 lines
2.0 KiB
Svelte
<script lang="ts">
|
|
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
|
import { loopVideo as loopVideoPreference, videoViewerMuted, videoViewerVolume } from '$lib/stores/preferences.store';
|
|
import { getAssetPlaybackUrl, getAssetThumbnailUrl } from '$lib/utils';
|
|
import { handleError } from '$lib/utils/handle-error';
|
|
import { AssetMediaSize } from '@immich/sdk';
|
|
import { createEventDispatcher } from 'svelte';
|
|
import { fade } from 'svelte/transition';
|
|
|
|
export let assetId: string;
|
|
export let loopVideo: boolean;
|
|
export let checksum: string;
|
|
|
|
let element: HTMLVideoElement | undefined = undefined;
|
|
let isVideoLoading = true;
|
|
let assetFileUrl: string;
|
|
|
|
$: {
|
|
const next = getAssetPlaybackUrl({ id: assetId, checksum });
|
|
if (assetFileUrl !== next) {
|
|
assetFileUrl = next;
|
|
element && element.load();
|
|
}
|
|
}
|
|
|
|
const dispatch = createEventDispatcher<{ onVideoEnded: void; onVideoStarted: void }>();
|
|
|
|
const handleCanPlay = async (event: Event) => {
|
|
try {
|
|
const video = event.currentTarget as HTMLVideoElement;
|
|
await video.play();
|
|
dispatch('onVideoStarted');
|
|
} catch (error) {
|
|
handleError(error, 'Unable to play video');
|
|
} finally {
|
|
isVideoLoading = false;
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<div
|
|
transition:fade={{ duration: 150 }}
|
|
class="flex select-none place-content-center place-items-center"
|
|
style="height: calc(100% - 64px)"
|
|
>
|
|
<video
|
|
bind:this={element}
|
|
loop={$loopVideoPreference && loopVideo}
|
|
autoplay
|
|
playsinline
|
|
controls
|
|
class="h-full object-contain"
|
|
on:canplay={handleCanPlay}
|
|
on:ended={() => dispatch('onVideoEnded')}
|
|
bind:muted={$videoViewerMuted}
|
|
bind:volume={$videoViewerVolume}
|
|
poster={getAssetThumbnailUrl({ id: assetId, size: AssetMediaSize.Preview, checksum })}
|
|
>
|
|
<source src={assetFileUrl} type="video/mp4" />
|
|
<track kind="captions" />
|
|
</video>
|
|
|
|
{#if isVideoLoading}
|
|
<div class="absolute flex place-content-center place-items-center">
|
|
<LoadingSpinner />
|
|
</div>
|
|
{/if}
|
|
</div>
|