Skip to content

Commit

Permalink
refactor(web): harden video can play method (immich-app#3745)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Aug 17, 2023
1 parent ce84f9c commit 8ba338f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions web/src/lib/components/asset-viewer/video-viewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit 8ba338f

Please sign in to comment.