fix(web): play videos on safari (#3748)
* fix(web): play videos on safari * autoplay --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
cdb45364c3
commit
2ff71b0d27
1 changed files with 6 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { api } from '@api';
|
||||
import { ThumbnailFormat, api } from '@api';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { videoViewerVolume } from '$lib/stores/preferences.store';
|
||||
|
@ -18,21 +18,24 @@
|
|||
video.muted = true;
|
||||
await video.play();
|
||||
video.muted = false;
|
||||
|
||||
isVideoLoading = false;
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to play video');
|
||||
} finally {
|
||||
isVideoLoading = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center">
|
||||
<video
|
||||
autoplay
|
||||
playsinline
|
||||
controls
|
||||
class="h-full object-contain"
|
||||
on:canplay={handleCanPlay}
|
||||
on:ended={() => dispatch('onVideoEnded')}
|
||||
bind:volume={$videoViewerVolume}
|
||||
poster={api.getAssetThumbnailUrl(assetId, ThumbnailFormat.Jpeg)}
|
||||
>
|
||||
<source src={api.getAssetFileUrl(assetId, false, true, publicSharedKey)} type="video/mp4" />
|
||||
<track kind="captions" />
|
||||
|
|
Loading…
Reference in a new issue