mirror of
https://github.com/smittix/intercept.git
synced 2026-07-08 01:28:13 -07:00
Add WebSocket audio fallback for listening
This commit is contained in:
@@ -2147,6 +2147,20 @@ async function _startDirectListenInternal() {
|
|||||||
console.log('[LISTEN] Initial play blocked, waiting for canplay');
|
console.log('[LISTEN] Initial play blocked, waiting for canplay');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fallback: if stream never starts, switch to WebSocket audio
|
||||||
|
setTimeout(async () => {
|
||||||
|
if (!isDirectListening || !audioPlayer) return;
|
||||||
|
if (audioPlayer.readyState > 0) return;
|
||||||
|
console.warn('[LISTEN] HTTP stream not ready, attempting WebSocket audio fallback');
|
||||||
|
await startWebSocketListen({
|
||||||
|
frequency: freq,
|
||||||
|
modulation: currentModulation,
|
||||||
|
squelch: squelch,
|
||||||
|
gain: gain,
|
||||||
|
device: device
|
||||||
|
}, audioPlayer);
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
// Initialize audio visualizer to feed signal levels to synthesizer
|
// Initialize audio visualizer to feed signal levels to synthesizer
|
||||||
initAudioVisualizer();
|
initAudioVisualizer();
|
||||||
|
|
||||||
@@ -2164,6 +2178,35 @@ async function _startDirectListenInternal() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function startWebSocketListen(config, audioPlayer) {
|
||||||
|
const selectedType = typeof getSelectedSDRType === 'function'
|
||||||
|
? getSelectedSDRType()
|
||||||
|
: getSelectedSDRTypeForScanner();
|
||||||
|
if (selectedType && selectedType !== 'rtlsdr') {
|
||||||
|
console.warn('[LISTEN] WebSocket audio supports RTL-SDR only');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Stop HTTP audio stream before switching
|
||||||
|
await fetch('/listening/audio/stop', { method: 'POST' });
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// Reset audio element for MediaSource
|
||||||
|
try {
|
||||||
|
audioPlayer.pause();
|
||||||
|
} catch (e) {}
|
||||||
|
audioPlayer.removeAttribute('src');
|
||||||
|
audioPlayer.load();
|
||||||
|
|
||||||
|
const ws = initWebSocketAudio();
|
||||||
|
if (!ws) return;
|
||||||
|
|
||||||
|
// Ensure MediaSource is set up
|
||||||
|
setupMediaSource(audioPlayer);
|
||||||
|
sendWebSocketCommand('start', config);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop direct listening
|
* Stop direct listening
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user