Add countdown audio per presentation
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:
1 parent
cad09163d9
commit
2f7a401522
16 files changed
+648
-11
No files matched your search
@@ -52,6 +52,8 @@ POLL_INTERVAL_MS=2000
|
||||
# UPLOADS_PATH=/var/www/plenario-uploads
|
||||
IMAGE_MAX_UPLOAD_MB=10
|
||||
IMAGE_MAX_PER_POLL=20
|
||||
# Countdown music of a presentation: largest upload in MB (PHP's upload_max_filesize and post_max_size must allow it)
|
||||
AUDIO_MAX_UPLOAD_MB=10
|
||||
# Embedded slides (/e/{key}/{slide}, e.g. Canva): heartbeat interval and timeout until pause (s)
|
||||
EMBED_HEARTBEAT_SECONDS=5
|
||||
EMBED_TIMEOUT_SECONDS=20
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
/**
|
||||
* Optional audio file per presentation, played in the presenter view while a quiz countdown runs.
|
||||
* The file lives in the upload directory, see \App\Service\AudioService; the table only holds its
|
||||
* random file name.
|
||||
*/
|
||||
class AddAudioToPolls extends BaseMigration
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$table = $this->table('polls');
|
||||
if (!$table->hasColumn('audio')) {
|
||||
$table->addColumn('audio', 'string', ['null' => true, 'default' => null, 'limit' => 40])->update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$table = $this->table('polls');
|
||||
if ($table->hasColumn('audio')) {
|
||||
$table->removeColumn('audio')->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,11 @@ return [
|
||||
// Slides with an image per poll.
|
||||
'maxPerPoll' => (int)env('IMAGE_MAX_PER_POLL', 20),
|
||||
],
|
||||
// Countdown audio of a presentation (see \App\Service\AudioService): stored as uploaded next to the images.
|
||||
'audio' => [
|
||||
// Largest accepted upload. PHP's upload_max_filesize/post_max_size must allow it.
|
||||
'maxUploadBytes' => (int)env('AUDIO_MAX_UPLOAD_MB', 10) * 1024 * 1024,
|
||||
],
|
||||
// Slides embedded in other presentation software (/e/{key}/{slide}, e.g. Canva).
|
||||
'embed' => [
|
||||
// A visible embedded slide reports every N seconds that it is still on screen ...
|
||||
|
||||
+7
-1
@@ -37,7 +37,11 @@ return function (RouteBuilder $routes): void {
|
||||
$builder->connect('/p/{code}/img/{file}', 'Participate::image', ['_name' => 'participate:image'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}', 'file' => '[a-f0-9]{24}\.webp'])
|
||||
->setPass(['code', 'file']);
|
||||
$builder->connect('/p/{code}/vote', 'Participate::vote', ['_name' => 'participate:vote'])
|
||||
// Countdown audio of a poll (played by the presenter view): random file name, only files of this poll.
|
||||
$builder->connect('/p/{code}/audio/{file}', 'Participate::audio', ['_name' => 'participate:audio'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}', 'file' => '[a-f0-9]{24}\.(mp3|ogg|wav|m4a)'])
|
||||
->setPass(['code', 'file']);
|
||||
$builder->connect('/p/{code}/vote','Participate::vote', ['_name' => 'participate:vote'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||
->setPass(['code'])
|
||||
->setMethods(['POST']);
|
||||
@@ -67,6 +71,8 @@ return function (RouteBuilder $routes): void {
|
||||
$admin->connect('/', 'Admin::index', ['_name' => 'admin'])->setPatterns($token);
|
||||
$admin->connect('/settings', 'Admin::settings', ['_name' => 'admin:settings'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/audio', 'Admin::audio', ['_name' => 'admin:audio'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/rotate-token', 'Admin::rotateToken', ['_name' => 'admin:rotate'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/rotate-embed-key', 'Admin::rotateEmbedKey', ['_name' => 'admin:rotate-embed'])
|
||||
|
||||
Reference in new issue
Block a user