Playlist: per-track start/end trim, total/elapsed/remaining times, waveform cards
- Per-track start/end points (mm:ss inputs, 'set to current' buttons, draggable handles on the waveform). Trim applied via audio.setTrim (seek to start, stop at end) and pushed live to the playing track. - Wider cards showing elapsed / total / remaining for the trimmed range. - Waveform rendered per track: peaks computed in main via ffmpeg (mono 8kHz PCM -> 400 normalized buckets, cached), drawn on a canvas with trim region + playhead. New audio:peaks IPC + djv.peaks preload binding. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
a8973619e6
commit
882dd4643a
6 files changed
+249
-18
No files matched your search
@@ -323,6 +323,7 @@ djv.onControl(async (m) => {
|
||||
try {
|
||||
// Switching to an audio track: stop/hide any playing video track.
|
||||
trackVideo.pause(); trackVideo.classList.remove('show');
|
||||
audio.setTrim(m.start || 0, m.end || 0);
|
||||
audio.onEnded = () => djv.report({ type: 'trackEnded' });
|
||||
await audio.loadFile(toFileURL(m.path), { loop: false, crossfade: m.crossfade || 0 });
|
||||
hideHint();
|
||||
@@ -331,6 +332,7 @@ djv.onControl(async (m) => {
|
||||
break;
|
||||
case 'playVideoTrack':
|
||||
try {
|
||||
audio.setTrim(m.start || 0, m.end || 0);
|
||||
audio.onEnded = () => djv.report({ type: 'trackEnded' });
|
||||
audio.attachVideo(trackVideo);
|
||||
trackVideo.loop = false; trackVideo.muted = false;
|
||||
@@ -341,6 +343,7 @@ djv.onControl(async (m) => {
|
||||
trackVideo.load();
|
||||
trackVideo.classList.add('show');
|
||||
await trackVideo.play();
|
||||
audio.seekToTrimStart(trackVideo);
|
||||
hideHint();
|
||||
djv.report({ type: 'playState', playing: true });
|
||||
} catch (e) { djv.report({ type: 'error', message: e.message }); }
|
||||
@@ -355,6 +358,7 @@ djv.onControl(async (m) => {
|
||||
djv.report({ type: 'playState', playing: true });
|
||||
} catch (e) { djv.report({ type: 'error', message: e.message }); }
|
||||
break;
|
||||
case 'setTrim': audio.setTrim(m.start || 0, m.end || 0); break;
|
||||
case 'probeDurations': probeDurations(m.paths || []); break;
|
||||
case 'togglePlay': {
|
||||
const playing = audio.togglePlay();
|
||||
@@ -470,6 +474,8 @@ function frame() {
|
||||
lastReport = now;
|
||||
djv.report({ type: 'meters', bass: a.bass, mid: a.mid, treble: a.treble, fps });
|
||||
}
|
||||
// Stop at the trim end point if one is set.
|
||||
audio.checkTrim();
|
||||
// Playback progress for the currently playing file.
|
||||
if (now - lastProgress > 400) {
|
||||
lastProgress = now;
|
||||
|
||||
Reference in new issue
Block a user