1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

refactor(web): harden video can play method (#3745)

This commit is contained in:
Jason Rasmussen 2023-08-17 11:02:12 -04:00 committed by GitHub
parent ce84f9c755
commit 8ba338fbe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,21 +4,25 @@
import { createEventDispatcher } from 'svelte';
import { videoViewerVolume } from '$lib/stores/preferences.store';
import LoadingSpinner from '../shared-components/loading-spinner.svelte';
import { handleError } from '../../utils/handle-error';
export let assetId: string;
export let publicSharedKey: string | undefined = undefined;
let isVideoLoading = true;
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{ onVideoEnded: void }>();
const handleCanPlay = (ev: Event & { currentTarget: HTMLVideoElement }) => {
const playerNode = ev.currentTarget;
const handleCanPlay = async (event: Event) => {
try {
const video = event.currentTarget as HTMLVideoElement;
video.muted = true;
await video.play();
video.muted = false;
playerNode.muted = true;
playerNode.play();
playerNode.muted = false;
isVideoLoading = false;
isVideoLoading = false;
} catch (error) {
handleError(error, 'Unable to play video');
}
};
</script>