mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Enable the mic automatically on page load instead of requiring a click
Voice activation already gates what's actually transmitted, so there's no reason to make the user click "Enable microphone" every time - it's now requested once on mount via the same handleToggleMic() path a manual click uses. Also resume the AudioContext if it starts suspended (autoplay policy), since granting the permission prompt itself counts as a user gesture and unblocks it even when start() wasn't triggered by a click.
This commit is contained in:
1 parent
41559c7712
commit
0d65c3b123
2 files changed
+14
No files matched your search
@@ -1190,6 +1190,16 @@ function App() {
|
||||
socketRef.current?.send(JSON.stringify({ type: "setInputMuted", muted: !inputMutedRef.current }));
|
||||
};
|
||||
|
||||
// Enable the mic automatically on page load (voice activation still gates
|
||||
// what's actually sent) instead of requiring an explicit click every time.
|
||||
const autoMicAttemptedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (autoMicAttemptedRef.current) return;
|
||||
autoMicAttemptedRef.current = true;
|
||||
void handleToggleMic();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const handleToggleOutputMuted = () => {
|
||||
socketRef.current?.send(JSON.stringify({ type: "setOutputMuted", muted: !outputMutedRef.current }));
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user