Playlist-video blend/opacity/fit controls + export/import playlist to file

- Blend mode, opacity and fit for videos played from the playlist (mix with visuals).
- Save/Load buttons to export/import a playlist (with scenes/cues) to a JSON file
  via native dialogs; the playlist already auto-persists between sessions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
lucianoandClaude Opus 4.8 committed 2026-06-19 16:52:55 +02:00
1 parent 0f0accc67d
commit 50b4223100
5 files changed
+89 -10

No files matched your search

+23
View File
@@ -51,12 +51,35 @@
<button id="btn-clear-playlist">🗑 Svuota</button>
<label class="chk"><input type="checkbox" id="repeat-playlist" /> Ripeti</label>
</div>
<div class="row">
<button id="btn-pl-save">💾 Salva playlist…</button>
<button id="btn-pl-load">📂 Carica playlist…</button>
</div>
<input type="file" id="tracks-input" accept="audio/*,video/*" multiple hidden />
<input type="file" id="scene-img-input" accept="image/*" hidden />
<ol id="playlist" class="playlist"></ol>
<div class="hint-mini">Clic sul <b>nome</b> = avvia/riavvia · ▶/⏸ pausa · ⠿ riordina · ⌨ tasto rapido · 🎬 <b>scena</b> (effetto+testo+immagine applicati quando parte il brano)</div>
</section>
<section>
<label>Resa video in playlist</label>
<select id="tvid-fit">
<option value="contain">Adatta (bordi neri)</option>
<option value="cover">Riempie schermo</option>
</select>
<label>Fusione</label>
<select id="tvid-blend">
<option value="normal">normale</option>
<option value="screen">screen</option>
<option value="overlay">overlay</option>
<option value="multiply">multiply</option>
<option value="lighten">lighten</option>
</select>
<label>Opacità <span id="tvid-op-val">100%</span></label>
<input type="range" id="tvid-op" min="0" max="100" step="1" value="100" />
<div class="hint-mini">Si applica al video riprodotto dalla playlist (per fonderlo con gli effetti).</div>
</section>
<section>
<label>Reattività <span id="gain-val">1.0×</span></label>
<input type="range" id="gain" min="0" max="3" step="0.05" value="1" />
+32 -7
View File
@@ -203,10 +203,14 @@ let sceneEditing = -1; // playlist index whose scene editor is open
let sceneImgTarget = -1, sceneCueTarget = -1; // track/cue awaiting an image
let activeCues = [], firedCue = -1; // cue schedule for the playing track
function serializePlaylist() {
return playlist.map(t => ({ path: t.path, name: t.name, key: t.key || null, cues: t.cues || [], isVideo: !!t.isVideo }));
}
function normalizeTrack(t) {
return { path: t.path, name: t.name || baseName(t.path), key: t.key || null, cues: Array.isArray(t.cues) ? t.cues : [], isVideo: !!t.isVideo };
}
function savePlaylistState() {
if (djv.savePlaylist) {
djv.savePlaylist(playlist.map(t => ({ path: t.path, name: t.name, key: t.key || null, cues: t.cues || [], isVideo: !!t.isVideo })));
}
if (djv.savePlaylist) djv.savePlaylist(serializePlaylist());
}
function hasScene(tr) {
@@ -430,6 +434,30 @@ $('#btn-clear-playlist').addEventListener('click', () => {
playlist = []; currentIndex = -1; sceneEditing = -1; renderPlaylist(); savePlaylistState();
});
$('#repeat-playlist').addEventListener('change', (e) => { repeat = e.target.checked; });
// Export / import the playlist to a file.
$('#btn-pl-save').addEventListener('click', async () => {
if (djv.exportPlaylist) await djv.exportPlaylist(serializePlaylist());
});
$('#btn-pl-load').addEventListener('click', async () => {
if (!djv.importPlaylist) return;
const data = await djv.importPlaylist();
if (Array.isArray(data)) {
playlist = data.map(normalizeTrack);
currentIndex = -1; sceneEditing = -1;
renderPlaylist(); savePlaylistState();
probePaths(playlist.map(t => t.path));
}
});
// Playlist-video rendering (blend / opacity / fit).
$('#tvid-fit').addEventListener('change', (e) => send({ type: 'trackVideoFit', value: e.target.value }));
$('#tvid-blend').addEventListener('change', (e) => send({ type: 'trackVideoBlend', value: e.target.value }));
$('#tvid-op').addEventListener('input', (e) => {
const v = parseInt(e.target.value, 10);
$('#tvid-op-val').textContent = v + '%';
send({ type: 'trackVideoOpacity', value: v / 100 });
});
$('#btn-use-input').addEventListener('click', () =>
send({ type: 'useInput', deviceId: $('#device-select').value || null }));
$('#output-select').addEventListener('change', (e) =>
@@ -670,10 +698,7 @@ if (padXfade) padXfade.addEventListener('input', (e) => {
try {
const saved = djv.loadPlaylist ? await djv.loadPlaylist() : null;
if (Array.isArray(saved) && saved.length) {
playlist = saved.map(t => ({
path: t.path, name: t.name || baseName(t.path),
key: t.key || null, cues: Array.isArray(t.cues) ? t.cues : [], isVideo: !!t.isVideo
}));
playlist = saved.map(normalizeTrack);
renderPlaylist();
probePaths(playlist.map(t => t.path));
}
+9 -1
View File
@@ -95,7 +95,12 @@ function composeFrame() {
}
if (trackVideo.classList.contains('show') && trackVideo.readyState >= 2 && trackVideo.videoWidth) {
try { drawMediaFit(recCtx, trackVideo, W, H, 'contain'); } catch (e) {}
recCtx.globalAlpha = parseFloat(getComputedStyle(trackVideo).opacity) || 1;
const bm = trackVideo.style.mixBlendMode;
recCtx.globalCompositeOperation = (bm && bm !== 'normal') ? bm : 'source-over';
try { drawMediaFit(recCtx, trackVideo, W, H, trackVideo.style.objectFit || 'contain'); } catch (e) {}
recCtx.globalAlpha = 1;
recCtx.globalCompositeOperation = 'source-over';
}
for (const im of images) {
@@ -356,6 +361,9 @@ djv.onControl(async (m) => {
case 'videoOpacity': bgVideo.style.opacity = m.value; break;
case 'videoFit': bgVideo.style.objectFit = m.value; break;
case 'videoBlend': bgVideo.style.mixBlendMode = m.value; break;
case 'trackVideoBlend': trackVideo.style.mixBlendMode = m.value; break;
case 'trackVideoOpacity': trackVideo.style.opacity = m.value; break;
case 'trackVideoFit': trackVideo.style.objectFit = m.value; break;
case 'sceneImage':
if (m.path) { sceneImage.src = toFileURL(m.path); sceneImage.classList.add('show'); hideHint(); }