fix muted video after click
This commit is contained in:
@@ -170,12 +170,17 @@ export function initLightbox () {
|
|||||||
state.lightbox.on('contentActivate', ({ content }: { content: { element?: HTMLElement } }) => {
|
state.lightbox.on('contentActivate', ({ content }: { content: { element?: HTMLElement } }) => {
|
||||||
const video = content.element?.querySelector('video')
|
const video = content.element?.querySelector('video')
|
||||||
if (video) {
|
if (video) {
|
||||||
video.play().catch(() => {
|
setTimeout(() => {
|
||||||
// Browsers block unmuted autoplay without a user gesture (e.g. a
|
video.play().catch((err: Error) => {
|
||||||
// deep link straight to a video slide) - retry muted.
|
// Only mute and retry if the browser explicitly blocked unmuted autoplay.
|
||||||
video.muted = true
|
if (err.name === 'NotAllowedError') {
|
||||||
video.play().catch(() => {})
|
video.muted = true
|
||||||
})
|
video.play().catch(() => {})
|
||||||
|
} else if (err.name === 'AbortError') {
|
||||||
|
video.play().catch(() => {})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 50)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user