fix(deprecations): remove dead ScriptProcessorNode PCM code (eliminates console warning); improve YouTube playerVars with origin/modestbranding (reduce postMessage spam); fix Timer stopwatch (now properly counts UP, clean display + interval)

Per PLAN item 7.
This commit is contained in:
2026-06-04 15:59:02 -04:00
parent 1bfc8333e9
commit eb5952adc6
3 changed files with 8 additions and 38 deletions
+2
View File
@@ -45,6 +45,8 @@ export default function MusicPlayer() {
loop: 1,
playlist: active.videoId,
enablejsapi: 1,
origin: window.location.origin,
modestbranding: 1,
},
events: {
onReady: (e: any) => {
+5 -5
View File
@@ -68,6 +68,9 @@ export default function Timer() {
if (!running) return;
intervalRef.current = setInterval(() => {
setRemaining((r) => {
if (mode === 'stopwatch') {
return r + 1; // count UP for stopwatch
}
if (r <= 1) {
stop();
if (mode === 'pomodoro') setSessions((s) => s + 1);
@@ -79,7 +82,7 @@ export default function Timer() {
return stop;
}, [running, mode, stop]);
const progress = presetMinutes > 0 ? 1 - remaining / (presetMinutes * 60) : 0;
const progress = mode === 'stopwatch' ? 0 : (presetMinutes > 0 ? 1 - remaining / (presetMinutes * 60) : 0);
return (
<div className="glass-card p-4">
@@ -112,10 +115,7 @@ export default function Timer() {
{/* Timer display */}
<div className="text-center py-2">
<div className="text-5xl font-extrabold tracking-widest text-kira-plum tabular-nums">
{mode === 'stopwatch'
? formatTime(Math.floor((presetMinutes * 60 - remaining + presetMinutes * 60) || remaining))
: formatTime(remaining)
}
{formatTime(remaining)}
</div>
{/* Progress bar */}
+1 -33
View File
@@ -307,36 +307,4 @@ function arrayBufferToBase64(buffer: ArrayBufferLike): string {
return btoa(binary);
}
/** Capture PCM16 mono 24kHz audio from mic and send via callback. */
function startPCMCapture(
stream: MediaStream,
onChunk: (pcm16: Uint8Array) => void,
): { stop: () => void } {
const ctx = new AudioContext({ sampleRate: 24000 });
const source = ctx.createMediaStreamSource(stream);
const processor = ctx.createScriptProcessor(4096, 1, 1);
let running = true;
processor.onaudioprocess = (e) => {
if (!running) return;
const input = e.inputBuffer.getChannelData(0);
const pcm16 = new Int16Array(input.length);
for (let i = 0; i < input.length; i++) {
const s = Math.max(-1, Math.min(1, input[i]));
pcm16[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
}
onChunk(new Uint8Array(pcm16.buffer));
};
source.connect(processor);
processor.connect(ctx.destination);
return {
stop: () => {
running = false;
source.disconnect();
processor.disconnect();
ctx.close();
},
};
}
// (Legacy PCM capture removed - MediaRecorder full-blob path is active; eliminates ScriptProcessorNode deprecation)