From c6523ac213dc821df1d8ebbcde3c3185a5d97f4c Mon Sep 17 00:00:00 2001 From: Denis Defolie Date: Fri, 30 Oct 2026 17:28:04 +0100 Subject: [PATCH] Media tab: several players per file type, chosen by long press Each type (sound, image, video) can now have 1 to 8 named players on /admin, reordered with the arrows; the first opens by default. A tap opens with it, a long press (or right click) on a file lists the others. The open_media message takes an optional opener id; the client can only name a player already configured for the file's type, and the command is still rebuilt from the database. Tablets receive player names and kinds (never the spec) and are notified on every change. media_openers (one row per type) becomes media_players; existing settings are migrated as unnamed players whose id is the type, so the old PUT /api/media/openers/ keeps working. A type always keeps a player. With real touch events the click following a long press landed on the chooser backdrop (closing it at once) or on one of its buttons (opening a player by mistake); clicks of the opening gesture are now ignored. Tests: store, migration, REST, WebSocket choice and refusals, and a Chromium test with touch long press, release click, Escape and right click. The UI tests no longer leave /admin before the token is stored. Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 15 ++- README-EN.md | 8 +- README.md | 9 +- mediadeck/admin.py | 57 ++++++++-- mediadeck/launchers.py | 147 ++++++++++++++++++++----- mediadeck/system.py | 24 +++- mediadeck/web/admin.html | 7 +- mediadeck/web/index.html | 11 ++ mediadeck/web/static/admin.css | 21 ++++ mediadeck/web/static/admin.js | 194 +++++++++++++++++++++++++-------- mediadeck/web/static/app.js | 156 +++++++++++++++++++++++++- mediadeck/web/static/style.css | 73 +++++++++++++ tests/test_admin.py | 106 ++++++++++++++---- tests/test_integration.py | 39 +++++++ tests/test_launchers.py | 151 ++++++++++++++++++++----- tests/test_ui_flows.py | 136 ++++++++++++++++++++--- 16 files changed, 980 insertions(+), 174 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 16d2448..d3fa266 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -86,7 +86,7 @@ Client → serveur : {"domain": "input", "action": "text", "text": "<1 à 500 caractères>"} // features.text_input ; erreur renvoyée pour les caractères impossibles {"domain": "system", "action": "power", "kind": "suspend|reboot|poweroff"} {"domain": "system", "action": "lock|launch", "id": ""} -{"domain": "system", "action": "open_media", "root": "", "path": ""} +{"domain": "system", "action": "open_media", "root": "", "path": "", "opener": ""} // sans "opener" : premier lecteur du type ; un id inconnu ou d'un autre type est refusé ``` - `seek` est relatif, en µs. Le client l'utilise de préférence à `set_position`, qui exige un trackid valide. @@ -124,8 +124,12 @@ GET /api/media?root=&path= {root, path, parent (null au sommet d' 400 chemin invalide / hors racine / pas un dossier ; 404 racine ou dossier inconnu ; route absente si aucun dossier GET /api/media/search?q=&root=&path= {query, root, entries:[{name, kind, root, folder, v?, size?}], truncated} ; root absent = toutes les racines ; 400 requête < 2 caractères, > 100, > 8 mots GET /thumb?root=&path=&size=160|320|640&token= image/jpeg (carré recadré), Cache-Control private 1 jour ; 401 sans jeton (dans l'URL comme /art), 400 taille/chemin invalide, 404 aucune miniature ; route montée seulement si ffmpeg est présent -GET /api/media/openers {openers:[{type, kind, spec}] (audio, image, video), kinds:[default,app,command], allow_command} (admin.enabled) -PUT /api/media/openers/{type} {kind, spec} → 200 ; 404 type inconnu ; 403 commande brute sans allow_custom_command (admin.enabled) +GET /api/media/openers {openers:[{id, type, label, kind, spec}] (par type audio, image, video, puis par ordre de préférence), kinds:[default,app,command], allow_command, max_per_type} (admin.enabled) +POST /api/media/openers {type, label, kind, spec} → 201 (id généré à partir du nom) ; 404 type inconnu ; 400 nom/limite (8 par type) ; 403 commande brute sans allow_custom_command +PUT /api/media/openers/{id} {label?, kind, spec} → 200 ; nom absent = inchangé ; l'ancienne adresse PUT /api/media/openers/ marche (le lecteur implicite ou migré a pour id son type) ; 404 inconnu ; 403 commande brute +DELETE /api/media/openers/{id} → 204 ; 400 si c'est le dernier lecteur du type +POST /api/media/openers/reorder {type, ids:[…]} (tous les lecteurs du type, une fois) → 204 ; le premier devient le lecteur par défaut + (toute modification de lecteur est répercutée aux tablettes : `system.media.openers`) ``` `kind`/`spec` des lecteurs : `default` → `{}` (`gio open `) ; `app` → `{desktop_id}` (`gio launch `) ; `command` → `{argv}` (le chemin est ajouté en **dernier argument**). @@ -152,7 +156,7 @@ La pochette locale (`file://`) n'est jamais transmise : elle est remplacée par - Les proxies dbus-next sont typés `Any`, car leurs méthodes `call_*` / `on_*` sont générées dynamiquement. - **Page des QR codes = fichier local, jamais une route du serveur** (`make qr`, `--qr`, module `qrpage.py`) : les QR codes contiennent le jeton, une route `/qr` le donnerait à tout le LAN (même limitée à la boucle locale, elle serait fragile derrière un proxy). Page autonome écrite en 600 dans `$XDG_RUNTIME_DIR/mediadeck/access.html` (tmpfs) et ouverte en `file://` : pas de CSP à contourner (`