diff --git a/assets/js/main.js b/assets/js/main.js index ff06f46..3e203f2 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -224,23 +224,25 @@ document.addEventListener('DOMContentLoaded', () => { const videoPlayer = document.getElementById('adsVideoPlayer'); if (videoPlayer) videoPlayer.volume = 0.1; + const text = locale === 'ar' ? (latest.dataset.announcementAr || '') : (latest.dataset.announcementEn || ''); + let audioObj = null; + if (text) { + const tl = locale === 'ar' ? 'ar' : 'en'; + const gTtsUrl = 'https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=' + tl + '&q=' + encodeURIComponent(text); + audioObj = new Audio(gTtsUrl); + audioObj.preload = 'auto'; // Force browser to start downloading + } + playChime(); setTimeout(() => { - const text = locale === 'ar' ? (latest.dataset.announcementAr || '') : (latest.dataset.announcementEn || ''); - if (text) { - // Use Google Translate TTS (outside high-quality voice API) - const tl = locale === 'ar' ? 'ar' : 'en'; - const gTtsUrl = 'https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=' + tl + '&q=' + encodeURIComponent(text); - - const audio = new Audio(gTtsUrl); - audio.onended = () => { if (videoPlayer) videoPlayer.volume = 1.0; }; + if (audioObj) { + audioObj.onended = () => { if (videoPlayer) videoPlayer.volume = 1.0; }; let fallbackPlayed = false; const handleFallback = (err) => { if (fallbackPlayed) return; fallbackPlayed = true; - // Fallback to built-in if external TTS fails console.warn("External TTS failed, falling back to built-in speech", err); if ('speechSynthesis' in window) { const utterance = new SpeechSynthesisUtterance(text); @@ -263,17 +265,16 @@ document.addEventListener('DOMContentLoaded', () => { if (videoPlayer) videoPlayer.volume = 1.0; } }; - audio.onerror = handleFallback; + audioObj.onerror = handleFallback; - // Attempt to play external audio - const playPromise = audio.play(); + const playPromise = audioObj.play(); if (playPromise !== undefined) { playPromise.catch(handleFallback); } } else { if (videoPlayer) videoPlayer.volume = 1.0; } - }, 1200); // play voice after chime finishes + }, 500); // reduced timeout from 1200ms to 500ms for faster playback } } } diff --git a/display.php b/display.php index 0ca23d1..81bc452 100644 --- a/display.php +++ b/display.php @@ -39,18 +39,18 @@ qh_page_start( padding-bottom: 0 !important; } @keyframes highlightPulse { - 0% { transform: scale(1); box-shadow: var(--shadow); border: 2px solid transparent; } - 50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(15, 139, 141, 0.6); border: 2px solid var(--accent-strong); } - 100% { transform: scale(1); box-shadow: var(--shadow); border: 2px solid transparent; } + 0% { transform: scale(1); box-shadow: var(--shadow); border: 2px solid transparent; background-color: #ffffff !important; } + 50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(15, 139, 141, 0.6); border: 2px solid var(--accent-strong); background-color: var(--accent-soft) !important; } + 100% { transform: scale(1); box-shadow: var(--shadow); border: 2px solid transparent; background-color: #ffffff !important; } } .blinking-ticket { animation: highlightPulse 1.5s ease-in-out infinite; z-index: 10; position: relative; - background-color: #fff !important; + /* removed */ } -