mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-02 16:45:15 -07:00
fix audio player freezing and improve UX
Switch WaveSurfer from MediaElement to WebAudio backend to prevent WKWebView deadlocks that were freezing the entire Tauri app during audio playback. Reuse a single WaveSurfer instance across track changes instead of destroying and recreating on every URL change, which was exhausting the browser's AudioContext pool. Other improvements: - spacebar play/pause with capture phase to prevent history item activation - drag-to-seek on waveform with silent scrub to avoid WebAudio popping - slider always mounted to prevent layout shift during track transitions - play button fills icon, accent bg when playing, loop button accent bg when active - fix AudioBars animation getting stuck by keying on mode - remove focus ring on history items - sync slider position on pause and during seek - remove title text from player bar - thicker cursor (3px)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useRef, useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { usePlatform } from '@/platform/PlatformContext';
|
||||
|
||||
interface UseSystemAudioCaptureOptions {
|
||||
@@ -94,15 +94,13 @@ export function useSystemAudioCapture({
|
||||
const blob = await platform.audio.stopSystemAudioCapture();
|
||||
|
||||
// Pass the actual recorded duration
|
||||
const recordedDuration = startTimeRef.current
|
||||
? (Date.now() - startTimeRef.current) / 1000
|
||||
const recordedDuration = startTimeRef.current
|
||||
? (Date.now() - startTimeRef.current) / 1000
|
||||
: undefined;
|
||||
onRecordingComplete?.(blob, recordedDuration);
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: 'Failed to stop system audio capture.';
|
||||
err instanceof Error ? err.message : 'Failed to stop system audio capture.';
|
||||
setError(errorMessage);
|
||||
}
|
||||
}, [isRecording, onRecordingComplete, platform]);
|
||||
|
||||
Reference in New Issue
Block a user