Add countdown audio per presentation
CI / Deploy / PHP 8.4 (push) Failing after 1m18s
CI / Deploy / PHP 8.5 (push) Failing after 2m4s
CI / Deploy / test (push) Failing after 1s
CI / Deploy / deploy (push) Skipped

One audio file per poll (MP3, M4A, OGG, WAV) is uploaded in the admin
settings and looped in the presenter view while a quiz runs. Format is
detected by magic bytes, files are served with a fixed content type,
copied with the poll and swept by images_cleanup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-21 11:36:01 +01:00
1 parent cad09163d9
commit 2f7a401522
16 files changed
+648 -11

No files matched your search

+66
View File
@@ -204,6 +204,70 @@
}
};
// ------------------------------------------------------------------ stage audio
/**
* Music of the presentation (presenter view only): plays in a loop while a quiz runs, so it also covers a
* countdown that is longer than the file, and stops when the quiz ends or the slide changes.
* Browsers may refuse to start audio without a previous click or key press; the presenter has
* always pressed something to start the quiz, and a refused start is retried on the next one.
*/
var StageAudio = {
element: null,
url: null,
wanted: false,
/** @param {string|null} url audio URL of the poll, only passed while a quiz is running */
sync: function (url) {
StageAudio.wanted = !!url;
if (!url) {
StageAudio.stop();
return;
}
if (!StageAudio.element) {
StageAudio.element = new Audio();
StageAudio.element.loop = true;
StageAudio.element.preload = 'auto';
}
var audio = StageAudio.element;
if (StageAudio.url !== url) {
StageAudio.url = url;
audio.src = url;
}
if (audio.paused) {
StageAudio.play();
}
},
play: function () {
var attempt = StageAudio.element && StageAudio.element.play();
if (attempt && attempt.catch) {
attempt.catch(function () {
// Blocked (no user activation yet): try again on the next click or key press.
var retry = function () {
document.removeEventListener('click', retry, true);
document.removeEventListener('keydown', retry, true);
if (StageAudio.wanted && StageAudio.element && StageAudio.element.paused) {
StageAudio.play();
}
};
document.addEventListener('click', retry, true);
document.addEventListener('keydown', retry, true);
});
}
},
stop: function () {
StageAudio.wanted = false;
if (StageAudio.element && !StageAudio.element.paused) {
StageAudio.element.pause();
}
if (StageAudio.element && StageAudio.element.currentTime) {
StageAudio.element.currentTime = 0;
}
}
};
// ------------------------------------------------------------------ word matching
/**
@@ -1454,6 +1518,7 @@
root.classList.remove('stage--video');
q('[data-voting]').hidden = true;
setText('[data-participants]', '');
StageAudio.stop();
return;
}
@@ -1498,6 +1563,7 @@
}
renderResults();
Countdown.start();
StageAudio.sync(quizPhase === 'running' ? state.poll.audioUrl : null);
}
function isPrivate() {