Wire up pressing the PTT button to unmute as well as spacebar
This commit is contained in:
parent
363f2340a0
commit
70c099c4b5
3 changed files with 30 additions and 12 deletions
|
@ -11,6 +11,8 @@ export function PTTButton({
|
||||||
activeSpeakerAvatarUrl,
|
activeSpeakerAvatarUrl,
|
||||||
activeSpeakerIsLocalUser,
|
activeSpeakerIsLocalUser,
|
||||||
size,
|
size,
|
||||||
|
startTalking,
|
||||||
|
stopTalking,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
@ -18,6 +20,8 @@ export function PTTButton({
|
||||||
[styles.talking]: activeSpeakerUserId,
|
[styles.talking]: activeSpeakerUserId,
|
||||||
[styles.error]: showTalkOverError,
|
[styles.error]: showTalkOverError,
|
||||||
})}
|
})}
|
||||||
|
onMouseDown={startTalking}
|
||||||
|
onMouseUp={stopTalking}
|
||||||
>
|
>
|
||||||
{activeSpeakerIsLocalUser || !activeSpeakerUserId ? (
|
{activeSpeakerIsLocalUser || !activeSpeakerUserId ? (
|
||||||
<MicIcon
|
<MicIcon
|
||||||
|
|
|
@ -45,6 +45,8 @@ export function PTTCallView({
|
||||||
talkOverEnabled,
|
talkOverEnabled,
|
||||||
setTalkOverEnabled,
|
setTalkOverEnabled,
|
||||||
activeSpeakerUserId,
|
activeSpeakerUserId,
|
||||||
|
startTalking,
|
||||||
|
stopTalking,
|
||||||
} = usePTT(client, groupCall, userMediaFeeds);
|
} = usePTT(client, groupCall, userMediaFeeds);
|
||||||
|
|
||||||
const activeSpeakerIsLocalUser =
|
const activeSpeakerIsLocalUser =
|
||||||
|
@ -115,6 +117,8 @@ export function PTTCallView({
|
||||||
activeSpeakerAvatarUrl={activeSpeakerAvatarUrl}
|
activeSpeakerAvatarUrl={activeSpeakerAvatarUrl}
|
||||||
activeSpeakerIsLocalUser={activeSpeakerIsLocalUser}
|
activeSpeakerIsLocalUser={activeSpeakerIsLocalUser}
|
||||||
size={pttButtonSize}
|
size={pttButtonSize}
|
||||||
|
startTalking={startTalking}
|
||||||
|
stopTalking={stopTalking}
|
||||||
/>
|
/>
|
||||||
<p className={styles.actionTip}>
|
<p className={styles.actionTip}>
|
||||||
{showTalkOverError
|
{showTalkOverError
|
||||||
|
|
|
@ -47,11 +47,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||||
};
|
};
|
||||||
}, [userMediaFeeds]);
|
}, [userMediaFeeds]);
|
||||||
|
|
||||||
useEffect(() => {
|
const startTalking = useCallback(() => {
|
||||||
function onKeyDown(event) {
|
|
||||||
if (event.code === "Space") {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
if (!activeSpeakerUserId || isAdmin || talkOverEnabled) {
|
if (!activeSpeakerUserId || isAdmin || talkOverEnabled) {
|
||||||
if (groupCall.isMicrophoneMuted()) {
|
if (groupCall.isMicrophoneMuted()) {
|
||||||
groupCall.setMicrophoneMuted(false);
|
groupCall.setMicrophoneMuted(false);
|
||||||
|
@ -59,6 +55,22 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||||
|
|
||||||
setState((prevState) => ({ ...prevState, pttButtonHeld: true }));
|
setState((prevState) => ({ ...prevState, pttButtonHeld: true }));
|
||||||
}
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const stopTalking = useCallback(() => {
|
||||||
|
if (!groupCall.isMicrophoneMuted()) {
|
||||||
|
groupCall.setMicrophoneMuted(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState((prevState) => ({ ...prevState, pttButtonHeld: false }));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function onKeyDown(event) {
|
||||||
|
if (event.code === "Space") {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
startTalking();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +78,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||||
if (event.code === "Space") {
|
if (event.code === "Space") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (!groupCall.isMicrophoneMuted()) {
|
stopTalking();
|
||||||
groupCall.setMicrophoneMuted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
setState((prevState) => ({ ...prevState, pttButtonHeld: false }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,5 +115,7 @@ export function usePTT(client, groupCall, userMediaFeeds) {
|
||||||
talkOverEnabled,
|
talkOverEnabled,
|
||||||
setTalkOverEnabled,
|
setTalkOverEnabled,
|
||||||
activeSpeakerUserId,
|
activeSpeakerUserId,
|
||||||
|
startTalking,
|
||||||
|
stopTalking,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue