From 41226d4514dd42d27bc40589ff0abf06fd7db696 Mon Sep 17 00:00:00 2001 From: John B Date: Fri, 12 Jun 2026 02:17:44 +0300 Subject: [PATCH] fix muted video after click --- app/src/client/lightbox.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/client/lightbox.ts b/app/src/client/lightbox.ts index 4018d43..a0c014c 100644 --- a/app/src/client/lightbox.ts +++ b/app/src/client/lightbox.ts @@ -170,12 +170,17 @@ export function initLightbox () { state.lightbox.on('contentActivate', ({ content }: { content: { element?: HTMLElement } }) => { const video = content.element?.querySelector('video') if (video) { - video.play().catch(() => { - // Browsers block unmuted autoplay without a user gesture (e.g. a - // deep link straight to a video slide) - retry muted. - video.muted = true - video.play().catch(() => {}) - }) + setTimeout(() => { + video.play().catch((err: Error) => { + // Only mute and retry if the browser explicitly blocked unmuted autoplay. + if (err.name === 'NotAllowedError') { + video.muted = true + video.play().catch(() => {}) + } else if (err.name === 'AbortError') { + video.play().catch(() => {}) + } + }) + }, 50) } }) }