fix: graceful mic-unavailable handling over HTTP
navigator.mediaDevices.getUserMedia() requires a secure context (HTTPS or localhost). When accessed over plain HTTP, the API is undefined. Now shows a friendly chat message instead of a cryptic TypeError in the console.
This commit is contained in:
@@ -193,6 +193,12 @@ export function useConversation() {
|
||||
// ── Audio ──
|
||||
|
||||
const startRecording = useCallback(async () => {
|
||||
// Check if mediaDevices is available (requires HTTPS/localhost)
|
||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||
addMessage('kira', 'Your browser needs HTTPS to use the microphone. Try accessing Kira through the HTTPS address instead!');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
streamRef.current = stream;
|
||||
|
||||
Reference in New Issue
Block a user