mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Experimental patch bridging postmessage events to PTT button
Listen for events on postmessage & use them to press the PTT button
This commit is contained in:
@@ -246,6 +246,26 @@ export const usePTT = (
|
|||||||
setMicMuteWrapper(true);
|
setMicMuteWrapper(true);
|
||||||
}, [setMicMuteWrapper]);
|
}, [setMicMuteWrapper]);
|
||||||
|
|
||||||
|
const onMessage = useCallback(
|
||||||
|
(e) => {
|
||||||
|
console.log("got message", e);
|
||||||
|
if (e.data === "pttp") {
|
||||||
|
startTalking();
|
||||||
|
} else if (e.data === "pttr") {
|
||||||
|
stopTalking();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[startTalking, stopTalking]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener("message", onMessage);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("message", onMessage);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// separate state for connected: we set it separately from other things
|
// separate state for connected: we set it separately from other things
|
||||||
// in the client sync callback
|
// in the client sync callback
|
||||||
const [connected, setConnected] = useState(true);
|
const [connected, setConnected] = useState(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user