mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-dj.git
synced 2026-11-29 06:22:06 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
parent
c3c132f810
commit
be6a590a81
22
README.md
22
README.md
@ -1,3 +1,21 @@
|
|||||||
# ploxion-dj
|
# 🎚 DJ
|
||||||
|
|
||||||
PLOXION · Table de mix du cubion son : 2 decks (A/B), crossfader, gains — combine les sources (spotify/radio) et pilote le mixer via le bus (dj.mix). · fournit: son, dj, mix
|
Table de mix du cubion son : 2 decks (A/B), crossfader, gains — combine les sources (spotify/radio) et pilote le mixer via le bus (dj.mix).
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `dj` |
|
||||||
|
| fournit | `son` `dj` `mix` |
|
||||||
|
| bions qu'il nomme | `jOSApps` `jOSPorts` `jOSStore` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/dj/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=dj — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre dj` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
|
|||||||
308
app.blade.php
Normal file
308
app.blade.php
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
{{-- PL0XI0N dj 🎚 — la TABLE DE MIX du cubion son (RS-7 : « le DJ combine les son-ploxions »).
|
||||||
|
2 decks A/B : chacun affiche sa source (titre) + son gain ; crossfader entre les deux ;
|
||||||
|
master global. Si window.jOSSound existe, ses sources réelles (spotify/radio/music…)
|
||||||
|
sont listées comme decks possibles (boutons vers A / vers B).
|
||||||
|
PORTS (bus jOSPorts, best-effort) :
|
||||||
|
OUT mix -> mixer.control : {xf,gainA,gainB,deckA,deckB} + master + gains{id:v}
|
||||||
|
(+ crossfade/a/b quand les 2 decks sont des sources jOSSound), émis à
|
||||||
|
CHAQUE changement, débounce ~200ms — le mixer l'applique aux sources.
|
||||||
|
IN deck <- spotify.track / radio.station (fan-in) : payload {title/name/...} pose
|
||||||
|
la source sur le deck LIBRE (A sinon B) et re-rend la table.
|
||||||
|
État persistant : jOSStore('dj') si dispo, sinon localStorage (toujours en try/catch).
|
||||||
|
window.jOSApps['dj'] : mount(c,ctx)->{unmount} ; unmount coupe bus + timers, vide le DOM. --}}
|
||||||
|
<style>
|
||||||
|
.djx{height:100%;display:flex;flex-direction:column;background:var(--xr-bg,#0b0e16);color:var(--xr-text,#e8eefc);font-family:var(--xr-font-ui,system-ui,sans-serif);font-size:.85rem}
|
||||||
|
.djx *{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
||||||
|
.djx__bar{flex:0 0 auto;display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--xr-border,rgba(127,140,170,.3))}
|
||||||
|
.djx__logo{font-size:1.15rem}
|
||||||
|
.djx__pill{margin-left:auto;font-size:.6rem;color:var(--xr-muted,#8a93a8);border:1px solid var(--xr-border,rgba(127,140,170,.3));border-radius:10px;padding:2px 8px;white-space:nowrap;transition:color .25s,border-color .25s}
|
||||||
|
.djx__pill.tx{color:var(--xr-accent,#7c5cff);border-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__body{flex:1;min-height:0;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:10px;width:100%}
|
||||||
|
.djx__decks{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px} /* minmax(0,…) : un titre long ne fait pas déborder la grille */
|
||||||
|
.djx__deck{border:1px solid var(--xr-border,rgba(127,140,170,.3));border-radius:14px;padding:10px;background:var(--xr-surface,rgba(127,140,170,.08));transition:border-color .2s,box-shadow .2s}
|
||||||
|
.djx__deck.hot{border-color:var(--xr-accent,#7c5cff);box-shadow:0 0 0 1px var(--xr-accent,#7c5cff) inset}
|
||||||
|
.djx__dhead{display:flex;align-items:center;gap:7px;min-height:26px}
|
||||||
|
.djx__badge{flex:0 0 auto;width:22px;height:22px;border-radius:7px;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:.72rem;background:var(--xr-accent,#7c5cff);color:#fff}
|
||||||
|
.djx__dtitle{flex:1;min-width:0;font-weight:700;font-size:.76rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
.djx__dtitle.free{color:var(--xr-muted,#8a93a8);font-weight:500;font-style:italic}
|
||||||
|
.djx__eject{flex:0 0 auto;width:24px;height:24px;border-radius:7px;border:1px solid var(--xr-border,rgba(127,140,170,.3));background:transparent;color:var(--xr-muted,#8a93a8);cursor:pointer;font-size:.68rem;line-height:1;padding:0}
|
||||||
|
.djx__eject:hover{color:var(--xr-text,#e8eefc);border-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__gain{display:flex;align-items:center;gap:7px;margin-top:9px}
|
||||||
|
.djx__glab{font-size:.58rem;text-transform:uppercase;letter-spacing:.06em;color:var(--xr-muted,#8a93a8)}
|
||||||
|
.djx__gain input{flex:1;min-width:0;accent-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__val{font-size:.66rem;color:var(--xr-muted,#8a93a8);width:36px;text-align:right;font-variant-numeric:tabular-nums;flex:0 0 auto}
|
||||||
|
.djx__card{border:1px solid var(--xr-border,rgba(127,140,170,.3));border-radius:14px;padding:11px 12px;background:var(--xr-surface,rgba(127,140,170,.08))}
|
||||||
|
.djx__xflab{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.62rem;color:var(--xr-muted,#8a93a8);margin-bottom:6px}
|
||||||
|
.djx__xfv{color:var(--xr-text,#e8eefc);font-weight:700;font-variant-numeric:tabular-nums}
|
||||||
|
.djx__xf{width:100%;height:30px;accent-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__mst{display:flex;align-items:center;gap:9px}
|
||||||
|
.djx__mlab{font-size:.72rem;font-weight:700;white-space:nowrap}
|
||||||
|
.djx__mst input{flex:1;min-width:0;accent-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__h{font-size:.6rem;text-transform:uppercase;letter-spacing:.09em;color:var(--xr-muted,#8a93a8);margin:4px 2px 0;display:flex;align-items:center;gap:6px}
|
||||||
|
.djx__hs{text-transform:none;letter-spacing:0}
|
||||||
|
.djx__srcs{display:flex;flex-direction:column;gap:7px}
|
||||||
|
.djx__srow{display:flex;align-items:center;gap:8px;border:1px solid var(--xr-border,rgba(127,140,170,.25));border-radius:11px;padding:8px 10px;background:var(--xr-surface,rgba(127,140,170,.06))}
|
||||||
|
.djx__srow.used{border-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__sic{font-size:1.05rem;flex:0 0 auto}
|
||||||
|
.djx__snm{flex:1;min-width:0;font-size:.76rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||||
|
.djx__snm small{display:block;font-weight:500;font-size:.6rem;color:var(--xr-muted,#8a93a8)}
|
||||||
|
.djx__to{flex:0 0 auto;border:1px solid var(--xr-border,rgba(127,140,170,.3));background:transparent;color:var(--xr-text,#e8eefc);border-radius:9px;padding:6px 9px;font-size:.68rem;font-weight:700;cursor:pointer;min-height:30px}
|
||||||
|
.djx__to:hover{border-color:var(--xr-accent,#7c5cff)}
|
||||||
|
.djx__to[disabled]{opacity:.4;cursor:default}
|
||||||
|
.djx__empty{border:1px dashed var(--xr-border,rgba(127,140,170,.3));border-radius:12px;padding:14px;font-size:.74rem;color:var(--xr-muted,#8a93a8);line-height:1.5;text-align:center}
|
||||||
|
@media (min-width:700px){ .djx__body{max-width:640px;margin:0 auto} }
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
function esc(s) { return window.jOSb.esc(s); }
|
||||||
|
function c01(v) { v = +v; return isFinite(v) ? Math.max(0, Math.min(1, v)) : 0; }
|
||||||
|
function r2(v) { return Math.round(v * 100) / 100; }
|
||||||
|
|
||||||
|
// sources réelles du bus audio partagé window.jOSSound (si présent) -> decks possibles
|
||||||
|
function sndList() {
|
||||||
|
try {
|
||||||
|
if (window.jOSSound && typeof window.jOSSound.list === 'function') {
|
||||||
|
return (window.jOSSound.list() || []).map(function (s) {
|
||||||
|
var label = '';
|
||||||
|
try { label = (s.label && s.label()) || s.name || s.id || ''; } catch (e) { label = s.name || s.id || ''; }
|
||||||
|
return { id: s.id, title: String(label), icon: s.icon || '🔊', kind: s.kind || 'son' };
|
||||||
|
}).filter(function (s) { return s.id != null; });
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function deckHtml(k) {
|
||||||
|
return '<div class="djx__deck" data-deck="' + k + '">'
|
||||||
|
+ '<div class="djx__dhead"><span class="djx__badge">' + k + '</span>'
|
||||||
|
+ '<span class="djx__dtitle" data-title="' + k + '"></span>'
|
||||||
|
+ '<button class="djx__eject" data-eject="' + k + '" title="libérer le deck ' + k + '">✕</button></div>'
|
||||||
|
+ '<div class="djx__gain"><span class="djx__glab">gain</span>'
|
||||||
|
+ '<input type="range" min="0" max="100" step="1" data-gain="' + k + '" aria-label="gain deck ' + k + '">'
|
||||||
|
+ '<span class="djx__val" data-gv="' + k + '"></span></div>'
|
||||||
|
+ '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function describe() {
|
||||||
|
var it = null;
|
||||||
|
try { if (window.jOSStore) { var S = window.jOSStore('dj', { key: 'mix', title: 'Table DJ' }); if (S && S.find) it = S.find(function (x) { return x && x.k === 'mix'; }); } } catch (e) {}
|
||||||
|
if (!it) { try { it = JSON.parse(localStorage.getItem('dj:mix')); } catch (e) {} }
|
||||||
|
var a = (it && it.deckA && it.deckA.title) || null, b = (it && it.deckB && it.deckB.title) || null;
|
||||||
|
return { v: 1, id: 'dj', title: 'DJ', icon: '🎚', items: [
|
||||||
|
{ p: 1, kind: 'stat', label: 'deck A', value: a || 'vide' },
|
||||||
|
{ p: 2, kind: 'stat', label: 'deck B', value: b || 'vide' }
|
||||||
|
] };
|
||||||
|
}
|
||||||
|
function mount(container, ctx) {
|
||||||
|
var alive = true, emitT = 0, sndUnsub = null, offDeck = null, pillT = 0;
|
||||||
|
var st = { xf: 0.5, gainA: 0.8, gainB: 0.8, master: 1, deckA: null, deckB: null };
|
||||||
|
|
||||||
|
// ---- état persistant : jOSStore('dj') si dispo (guard), sinon localStorage ----
|
||||||
|
function store() { try { return window.jOSStore ? window.jOSStore('dj', { key: 'mix', title: 'Table DJ' }) : null; } catch (e) { return null; } }
|
||||||
|
function loadState() {
|
||||||
|
var it = null;
|
||||||
|
try { var S = store(); if (S && S.find) it = S.find(function (x) { return x && x.k === 'mix'; }); } catch (e) {}
|
||||||
|
if (!it) { try { it = JSON.parse(localStorage.getItem('dj:mix')); } catch (e) {} }
|
||||||
|
if (!it || typeof it !== 'object') return;
|
||||||
|
if (it.xf != null && isFinite(+it.xf)) st.xf = c01(it.xf);
|
||||||
|
if (it.gainA != null && isFinite(+it.gainA)) st.gainA = c01(it.gainA);
|
||||||
|
if (it.gainB != null && isFinite(+it.gainB)) st.gainB = c01(it.gainB);
|
||||||
|
if (it.master != null && isFinite(+it.master)) st.master = c01(it.master);
|
||||||
|
if (it.deckA && typeof it.deckA === 'object' && it.deckA.title) st.deckA = { id: it.deckA.id || null, title: String(it.deckA.title).slice(0, 80), icon: it.deckA.icon || '' };
|
||||||
|
if (it.deckB && typeof it.deckB === 'object' && it.deckB.title) st.deckB = { id: it.deckB.id || null, title: String(it.deckB.title).slice(0, 80), icon: it.deckB.icon || '' };
|
||||||
|
}
|
||||||
|
function saveState() {
|
||||||
|
var data = { k: 'mix', xf: r2(st.xf), gainA: r2(st.gainA), gainB: r2(st.gainB), master: r2(st.master), deckA: st.deckA, deckB: st.deckB };
|
||||||
|
try { var S = store(); if (S && S.upsert) { S.upsert(function (x) { return x && x.k === 'mix'; }, data); return; } } catch (e) {}
|
||||||
|
try { localStorage.setItem('dj:mix', JSON.stringify(data)); } catch (e) {}
|
||||||
|
}
|
||||||
|
loadState();
|
||||||
|
|
||||||
|
container.innerHTML =
|
||||||
|
'<div class="djx">'
|
||||||
|
+ '<div class="djx__bar"><span class="djx__logo">🎚</span><b>DJ</b><span class="djx__pill" data-pill>crossfade + gains → mixer</span></div>'
|
||||||
|
+ '<div class="djx__body">'
|
||||||
|
+ '<div class="djx__decks">' + deckHtml('A') + deckHtml('B') + '</div>'
|
||||||
|
+ '<div class="djx__card"><div class="djx__xflab"><span>deck A</span><span class="djx__xfv" data-xfv></span><span>deck B</span></div>'
|
||||||
|
+ '<input class="djx__xf" type="range" min="0" max="100" step="1" data-xf aria-label="crossfader"></div>'
|
||||||
|
+ '<div class="djx__card djx__mst"><span class="djx__mlab">🔊 master</span><input type="range" min="0" max="100" step="1" data-master aria-label="volume master"><span class="djx__val" data-mv></span></div>'
|
||||||
|
+ '<div class="djx__h">sources <span class="djx__hs" data-srch></span></div>'
|
||||||
|
+ '<div class="djx__srcs" data-srcs></div>'
|
||||||
|
+ '</div></div>';
|
||||||
|
|
||||||
|
var root = container.querySelector('.djx');
|
||||||
|
var xfEl = root.querySelector('[data-xf]'), xfvEl = root.querySelector('[data-xfv]');
|
||||||
|
var mEl = root.querySelector('[data-master]'), mvEl = root.querySelector('[data-mv]');
|
||||||
|
var srcsEl = root.querySelector('[data-srcs]'), srchEl = root.querySelector('[data-srch]');
|
||||||
|
var pillEl = root.querySelector('[data-pill]');
|
||||||
|
|
||||||
|
// ---- rendu granulaire (on ne reconstruit jamais un slider pendant un drag) ----
|
||||||
|
function updateDeckUI(k) {
|
||||||
|
var d = (k === 'A') ? st.deckA : st.deckB;
|
||||||
|
var box = root.querySelector('[data-deck="' + k + '"]');
|
||||||
|
var t = root.querySelector('[data-title="' + k + '"]');
|
||||||
|
var ej = root.querySelector('[data-eject="' + k + '"]');
|
||||||
|
if (d) { t.innerHTML = (d.icon ? esc(d.icon) + ' ' : '') + esc(d.title); t.classList.remove('free'); ej.style.display = ''; }
|
||||||
|
else { t.textContent = '— libre —'; t.classList.add('free'); ej.style.display = 'none'; }
|
||||||
|
var g = (k === 'A') ? st.gainA : st.gainB;
|
||||||
|
var gi = root.querySelector('[data-gain="' + k + '"]'), gv = root.querySelector('[data-gv="' + k + '"]');
|
||||||
|
gi.value = String(Math.round(g * 100)); gv.textContent = Math.round(g * 100) + '%';
|
||||||
|
box.classList.toggle('on', !!d);
|
||||||
|
}
|
||||||
|
function updateXfUI() {
|
||||||
|
xfEl.value = String(Math.round(st.xf * 100));
|
||||||
|
xfvEl.textContent = 'A ' + Math.round((1 - st.xf) * 100) + '% · B ' + Math.round(st.xf * 100) + '%';
|
||||||
|
root.querySelector('[data-deck="A"]').classList.toggle('hot', st.xf <= 0.5);
|
||||||
|
root.querySelector('[data-deck="B"]').classList.toggle('hot', st.xf >= 0.5);
|
||||||
|
}
|
||||||
|
function updateMasterUI() { mEl.value = String(Math.round(st.master * 100)); mvEl.textContent = Math.round(st.master * 100) + '%'; }
|
||||||
|
|
||||||
|
function renderSources() {
|
||||||
|
var L = sndList();
|
||||||
|
srchEl.textContent = window.jOSSound ? (L.length + ' via jOSSound') : 'bus son indisponible';
|
||||||
|
if (!L.length) {
|
||||||
|
srcsEl.innerHTML = '<div class="djx__empty">' + (window.jOSSound
|
||||||
|
? 'Aucune source active. Ouvre <b>Spotify</b>, <b>Radio</b>, <b>Music</b>… — elles apparaîtront ici comme decks possibles.'
|
||||||
|
: 'Pas de bus son sur cette page — les decks arrivent quand même par le bus (dj.deck).') + '</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
srcsEl.innerHTML = L.map(function (s) {
|
||||||
|
var onA = !!(st.deckA && st.deckA.id === s.id), onB = !!(st.deckB && st.deckB.id === s.id);
|
||||||
|
return '<div class="djx__srow' + ((onA || onB) ? ' used' : '') + '">'
|
||||||
|
+ '<span class="djx__sic">' + esc(s.icon) + '</span>'
|
||||||
|
+ '<span class="djx__snm">' + esc(s.title) + '<small>' + esc(s.kind) + (onA ? ' · deck A' : '') + (onB ? ' · deck B' : '') + '</small></span>'
|
||||||
|
+ '<button class="djx__to" data-to="A" data-sid="' + esc(String(s.id)) + '"' + (onA ? ' disabled' : '') + '>→ A</button>'
|
||||||
|
+ '<button class="djx__to" data-to="B" data-sid="' + esc(String(s.id)) + '"' + (onB ? ' disabled' : '') + '>→ B</button>'
|
||||||
|
+ '</div>';
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- OUT dj.mix -> mixer.control : émis à chaque changement, débounce ~200ms ----
|
||||||
|
// gains{id} = gain du deck × poids du crossfader (valeur FINALE par source) ; on joint
|
||||||
|
// aussi crossfade/a/b quand les 2 decks portent un id jOSSound — le mixer gère les deux.
|
||||||
|
function mixPayload() {
|
||||||
|
var p = {
|
||||||
|
xf: r2(st.xf), gainA: r2(st.gainA), gainB: r2(st.gainB),
|
||||||
|
deckA: st.deckA ? { id: st.deckA.id || null, title: st.deckA.title } : null,
|
||||||
|
deckB: st.deckB ? { id: st.deckB.id || null, title: st.deckB.title } : null,
|
||||||
|
master: r2(st.master)
|
||||||
|
};
|
||||||
|
var g = {};
|
||||||
|
if (st.deckA && st.deckA.id) g[st.deckA.id] = r2(st.gainA * (1 - st.xf));
|
||||||
|
if (st.deckB && st.deckB.id) g[st.deckB.id] = r2(st.gainB * st.xf);
|
||||||
|
if ((st.deckA && st.deckA.id) || (st.deckB && st.deckB.id)) p.gains = g;
|
||||||
|
if (st.deckA && st.deckA.id && st.deckB && st.deckB.id) { p.crossfade = r2(st.xf); p.a = st.deckA.id; p.b = st.deckB.id; }
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
function flashPill() {
|
||||||
|
if (!pillEl) return;
|
||||||
|
pillEl.classList.add('tx');
|
||||||
|
if (pillT) clearTimeout(pillT);
|
||||||
|
pillT = setTimeout(function () { pillT = 0; if (alive) pillEl.classList.remove('tx'); }, 450);
|
||||||
|
}
|
||||||
|
function scheduleEmit() {
|
||||||
|
if (emitT) clearTimeout(emitT);
|
||||||
|
emitT = setTimeout(function () {
|
||||||
|
emitT = 0; if (!alive) return;
|
||||||
|
saveState();
|
||||||
|
try { if (window.jOSPorts && window.jOSPorts.emit) { window.jOSPorts.emit('dj', 'mix', mixPayload()); flashPill(); } } catch (e) {}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- pose d'une source sur un deck ----
|
||||||
|
function setDeck(k, d) {
|
||||||
|
if (d && d.id != null) { // une même source jOSSound ne vit que sur UN deck
|
||||||
|
if (k !== 'A' && st.deckA && st.deckA.id === d.id) { st.deckA = null; updateDeckUI('A'); }
|
||||||
|
if (k !== 'B' && st.deckB && st.deckB.id === d.id) { st.deckB = null; updateDeckUI('B'); }
|
||||||
|
}
|
||||||
|
if (k === 'A') st.deckA = d; else st.deckB = d;
|
||||||
|
updateDeckUI(k); renderSources(); scheduleEmit();
|
||||||
|
}
|
||||||
|
function placeDeck(d) {
|
||||||
|
// déjà posée (même id ou même titre) -> on met à jour CE deck (pas de doublon)
|
||||||
|
if (st.deckA && ((d.id && st.deckA.id === d.id) || st.deckA.title === d.title)) { setDeck('A', d); return; }
|
||||||
|
if (st.deckB && ((d.id && st.deckB.id === d.id) || st.deckB.title === d.title)) { setDeck('B', d); return; }
|
||||||
|
setDeck(!st.deckA ? 'A' : 'B', d); // deck libre : A sinon B (B remplacé si tout est pris)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- IN dj.deck : normalise {title/name/...}, ignore l'invalide et __wired/__via ----
|
||||||
|
function normDeck(p) {
|
||||||
|
if (p == null) return null;
|
||||||
|
if (typeof p === 'string') {
|
||||||
|
var s = p.trim(); if (!s) return null;
|
||||||
|
if (s.charAt(0) === '{') { try { p = JSON.parse(s); } catch (e) { return s.length <= 160 ? { id: null, title: s.slice(0, 80), icon: '' } : null; } }
|
||||||
|
else return s.length <= 160 ? { id: null, title: s.slice(0, 80), icon: '' } : null;
|
||||||
|
}
|
||||||
|
if (typeof p !== 'object' || Array.isArray(p)) return null;
|
||||||
|
var title = null, tk = ['title', 'name', 'label', 'station', 'track', 'song'], i;
|
||||||
|
for (i = 0; i < tk.length; i++) { var v = p[tk[i]]; if (typeof v === 'string' && v.trim()) { title = v.trim(); break; } }
|
||||||
|
if (!title && typeof p.uri === 'string' && p.uri) title = p.uri.split(':').pop().split('/').pop();
|
||||||
|
if (!title) return null; // payload invalide (ou juste __wired/__via) -> ignoré
|
||||||
|
var id = (typeof p.id === 'string' && p.id) ? p.id : ((typeof p.source === 'string' && p.source) ? p.source : null);
|
||||||
|
if (!id) { // résout l'id jOSSound par le titre (pour que gains{id} atteigne le mixer)
|
||||||
|
var L = sndList(), tl = title.toLowerCase(), j;
|
||||||
|
for (j = 0; j < L.length; j++) {
|
||||||
|
var cl = (L[j].title || '').toLowerCase();
|
||||||
|
if (cl && (cl.indexOf(tl) !== -1 || tl.indexOf(cl) !== -1)) { id = L[j].id; break; }
|
||||||
|
}
|
||||||
|
if (!id && typeof p.uri === 'string' && p.uri.indexOf('spotify') === 0) {
|
||||||
|
for (j = 0; j < L.length; j++) if (String(L[j].id).toLowerCase().indexOf('spotify') === 0) { id = L[j].id; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var icon = (typeof p.icon === 'string' && p.icon.length <= 8) ? p.icon : '';
|
||||||
|
return { id: id, title: title.slice(0, 80), icon: icon };
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (window.jOSPorts && window.jOSPorts.on) {
|
||||||
|
offDeck = window.jOSPorts.on('ploxion.dj.deck', function (p) {
|
||||||
|
if (!alive) return;
|
||||||
|
var d = normDeck(p); if (!d) return;
|
||||||
|
placeDeck(d); // pose sur le deck libre (A sinon B) + re-render + ré-émet le mix
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// ---- interactions ----
|
||||||
|
xfEl.addEventListener('input', function () { st.xf = c01((+xfEl.value) / 100); updateXfUI(); scheduleEmit(); });
|
||||||
|
mEl.addEventListener('input', function () { st.master = c01((+mEl.value) / 100); mvEl.textContent = mEl.value + '%'; scheduleEmit(); });
|
||||||
|
root.querySelectorAll('[data-gain]').forEach(function (r) {
|
||||||
|
r.addEventListener('input', function () {
|
||||||
|
var k = r.getAttribute('data-gain'), v = c01((+r.value) / 100);
|
||||||
|
if (k === 'A') st.gainA = v; else st.gainB = v;
|
||||||
|
var gv = root.querySelector('[data-gv="' + k + '"]'); if (gv) gv.textContent = r.value + '%';
|
||||||
|
scheduleEmit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
root.addEventListener('click', function (e) {
|
||||||
|
var ej = e.target.closest ? e.target.closest('[data-eject]') : null;
|
||||||
|
if (ej) { var k = ej.getAttribute('data-eject'); if (k === 'A') st.deckA = null; else st.deckB = null; updateDeckUI(k); renderSources(); scheduleEmit(); return; }
|
||||||
|
var to = e.target.closest ? e.target.closest('[data-to]') : null;
|
||||||
|
if (to && !to.disabled) {
|
||||||
|
var deck = to.getAttribute('data-to'), sid = to.getAttribute('data-sid');
|
||||||
|
var L = sndList(), s = null, i;
|
||||||
|
for (i = 0; i < L.length; i++) if (String(L[i].id) === sid) { s = L[i]; break; }
|
||||||
|
if (s) setDeck(deck, { id: s.id, title: s.title, icon: s.icon });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// sources live : la liste se re-rend quand une source s'inscrit/se retire du bus son
|
||||||
|
try { if (window.jOSSound && typeof window.jOSSound.subscribe === 'function') sndUnsub = window.jOSSound.subscribe(function () { if (alive) renderSources(); }); } catch (e) {}
|
||||||
|
|
||||||
|
updateDeckUI('A'); updateDeckUI('B'); updateXfUI(); updateMasterUI(); renderSources();
|
||||||
|
scheduleEmit(); // état initial -> le mixer se synchronise dès l'ouverture
|
||||||
|
|
||||||
|
return { unmount: function () {
|
||||||
|
alive = false;
|
||||||
|
if (emitT) { clearTimeout(emitT); emitT = 0; }
|
||||||
|
if (pillT) { clearTimeout(pillT); pillT = 0; }
|
||||||
|
if (offDeck) { try { offDeck(); } catch (e) {} }
|
||||||
|
if (sndUnsub) { try { sndUnsub(); } catch (e) {} }
|
||||||
|
container.innerHTML = '';
|
||||||
|
} };
|
||||||
|
}
|
||||||
|
|
||||||
|
window.jOSApps = window.jOSApps || {};
|
||||||
|
window.jOSApps['dj'] = { manifest: { id: 'dj', name: 'DJ', icon: '🎚' }, mount: mount, describe: describe };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user