mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 20:25:32 -04:00
fix(web): not autoplay after moving playhead on paused video (#17038)
fix(web): prevent autoplay after moving playhead
This commit is contained in:
parent
4a0045db44
commit
9757f70064
@ -38,6 +38,7 @@
|
|||||||
let isLoading = $state(true);
|
let isLoading = $state(true);
|
||||||
let assetFileUrl = $state('');
|
let assetFileUrl = $state('');
|
||||||
let forceMuted = $state(false);
|
let forceMuted = $state(false);
|
||||||
|
let isScrubbing = $state(false);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (videoPlayer) {
|
if (videoPlayer) {
|
||||||
@ -55,8 +56,10 @@
|
|||||||
|
|
||||||
const handleCanPlay = async (video: HTMLVideoElement) => {
|
const handleCanPlay = async (video: HTMLVideoElement) => {
|
||||||
try {
|
try {
|
||||||
await video.play();
|
if (!video.paused && !isScrubbing) {
|
||||||
onVideoStarted();
|
await video.play();
|
||||||
|
onVideoStarted();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof DOMException && error.name === 'NotAllowedError' && !forceMuted) {
|
if (error instanceof DOMException && error.name === 'NotAllowedError' && !forceMuted) {
|
||||||
await tryForceMutedPlay(video);
|
await tryForceMutedPlay(video);
|
||||||
@ -119,6 +122,8 @@
|
|||||||
$videoViewerMuted = e.currentTarget.muted;
|
$videoViewerMuted = e.currentTarget.muted;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onseeking={() => (isScrubbing = true)}
|
||||||
|
onseeked={() => (isScrubbing = false)}
|
||||||
onclose={() => onClose()}
|
onclose={() => onClose()}
|
||||||
muted={forceMuted || $videoViewerMuted}
|
muted={forceMuted || $videoViewerMuted}
|
||||||
bind:volume={$videoViewerVolume}
|
bind:volume={$videoViewerVolume}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user