DONE: enable sound by default on display tv, disable build images when pushing to main branch

This commit is contained in:
ISMAIL MASSERAN
2026-07-27 11:55:33 +08:00
parent 08fe762426
commit dd67b5d0a8
4 changed files with 27 additions and 49 deletions
@@ -76,22 +76,41 @@ export default function AdCarousel({ tenantCode }) {
const video = videoRef.current;
if (!video || currentAd?.mediaType !== 'VIDEO') return undefined;
let removeUnmuteListener = () => {};
const onEnded = () => goNext();
const scheduleFallbackAdvance = () => {
clearTimer();
const durationMs = Math.max(5, Number(currentAd.durationSeconds) || 15) * 1000;
timerRef.current = setTimeout(goNext, durationMs);
};
video.addEventListener('ended', onEnded);
video.muted = true;
video.muted = false;
video.playsInline = true;
const playPromise = video.play();
if (playPromise?.catch) {
playPromise.catch(() => {
// Autoplay blocked — advance after durationSeconds fallback
clearTimer();
const durationMs = Math.max(5, Number(currentAd.durationSeconds) || 15) * 1000;
timerRef.current = setTimeout(goNext, durationMs);
// Unmuted autoplay blocked — keep video playing muted, then unmute on gesture.
video.muted = true;
const mutedPlay = video.play();
if (mutedPlay?.catch) {
mutedPlay.catch(scheduleFallbackAdvance);
}
const unmute = () => {
video.muted = false;
video.play()?.catch(() => {});
};
window.addEventListener('pointerdown', unmute, { once: true });
removeUnmuteListener = () => window.removeEventListener('pointerdown', unmute);
});
}
return () => {
video.removeEventListener('ended', onEnded);
removeUnmuteListener();
};
}, [currentAd, goNext, clearTimer]);
@@ -127,7 +146,6 @@ export default function AdCarousel({ tenantCode }) {
ref={videoRef}
className="branch-display__ad-media"
src={src}
muted
playsInline
autoPlay
/>