2024-06-05 19:26:27 +08:00
|
|
|
import React, {
|
|
|
|
useCallback,
|
|
|
|
useEffect,
|
|
|
|
useState,
|
|
|
|
} from 'react';
|
2017-10-11 02:03:29 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2019-03-29 05:53:42 +08:00
|
|
|
import {
|
2020-05-26 04:00:13 +08:00
|
|
|
defineMessages, injectIntl, FormattedMessage,
|
2019-03-29 05:53:42 +08:00
|
|
|
} from 'react-intl';
|
2024-04-23 22:44:33 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2021-11-09 21:22:59 +08:00
|
|
|
import Styled from './styles';
|
2017-03-25 00:01:35 +08:00
|
|
|
import AudioSettings from '../audio-settings/component';
|
2017-10-04 04:42:10 +08:00
|
|
|
import EchoTest from '../echo-test/component';
|
2017-11-17 19:52:48 +08:00
|
|
|
import Help from '../help/component';
|
2019-04-11 04:51:06 +08:00
|
|
|
import AudioDial from '../audio-dial/component';
|
2019-08-03 05:32:42 +08:00
|
|
|
import AudioAutoplayPrompt from '../autoplay/component';
|
2024-05-29 21:26:11 +08:00
|
|
|
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
|
2024-04-04 21:22:26 +08:00
|
|
|
import usePreviousValue from '/imports/ui/hooks/usePreviousValue';
|
2024-04-23 22:44:33 +08:00
|
|
|
import { SET_AWAY } from '/imports/ui/components/user-list/user-list-content/user-participants/user-list-participants/user-actions/mutations';
|
2024-06-17 19:54:03 +08:00
|
|
|
import VideoService from '/imports/ui/components/video-provider/service';
|
2024-04-17 06:39:29 +08:00
|
|
|
import AudioCaptionsSelectContainer from '../audio-graphql/audio-captions/captions/component';
|
2024-04-25 04:06:53 +08:00
|
|
|
import useToggleVoice from '/imports/ui/components/audio/audio-graphql/hooks/useToggleVoice';
|
|
|
|
import {
|
|
|
|
muteAway,
|
|
|
|
} from '/imports/ui/components/audio/audio-graphql/audio-controls/input-stream-live-selector/service';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2024-06-05 19:26:27 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2018-12-03 14:01:19 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
const propTypes = {
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
closeModal: PropTypes.func.isRequired,
|
|
|
|
joinMicrophone: PropTypes.func.isRequired,
|
|
|
|
joinListenOnly: PropTypes.func.isRequired,
|
|
|
|
joinEchoTest: PropTypes.func.isRequired,
|
|
|
|
exitAudio: PropTypes.func.isRequired,
|
|
|
|
leaveEchoTest: PropTypes.func.isRequired,
|
|
|
|
changeInputDevice: PropTypes.func.isRequired,
|
|
|
|
changeOutputDevice: PropTypes.func.isRequired,
|
|
|
|
isEchoTest: PropTypes.bool.isRequired,
|
|
|
|
isConnecting: PropTypes.bool.isRequired,
|
|
|
|
isConnected: PropTypes.bool.isRequired,
|
2021-04-30 05:03:18 +08:00
|
|
|
isUsingAudio: PropTypes.bool.isRequired,
|
2024-04-17 01:33:23 +08:00
|
|
|
isListenOnly: PropTypes.bool.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
isMuted: PropTypes.bool.isRequired,
|
|
|
|
toggleMuteMicrophoneSystem: PropTypes.func.isRequired,
|
2017-10-23 20:41:09 +08:00
|
|
|
inputDeviceId: PropTypes.string,
|
|
|
|
outputDeviceId: PropTypes.string,
|
2019-04-16 00:39:36 +08:00
|
|
|
formattedDialNum: PropTypes.string.isRequired,
|
2018-03-02 20:01:34 +08:00
|
|
|
listenOnlyMode: PropTypes.bool.isRequired,
|
2021-02-05 02:42:31 +08:00
|
|
|
joinFullAudioImmediately: PropTypes.bool,
|
2018-03-06 04:00:52 +08:00
|
|
|
forceListenOnlyAttendee: PropTypes.bool.isRequired,
|
2019-06-28 00:02:42 +08:00
|
|
|
audioLocked: PropTypes.bool.isRequired,
|
2019-07-19 22:45:04 +08:00
|
|
|
resolve: PropTypes.func,
|
2019-06-28 00:02:42 +08:00
|
|
|
isMobileNative: PropTypes.bool.isRequired,
|
2021-04-03 02:11:46 +08:00
|
|
|
isIE: PropTypes.bool.isRequired,
|
2019-06-28 00:02:42 +08:00
|
|
|
formattedTelVoice: PropTypes.string.isRequired,
|
2019-08-03 05:32:42 +08:00
|
|
|
autoplayBlocked: PropTypes.bool.isRequired,
|
|
|
|
handleAllowAutoplay: PropTypes.func.isRequired,
|
2022-04-19 04:05:26 +08:00
|
|
|
changeInputStream: PropTypes.func.isRequired,
|
|
|
|
localEchoEnabled: PropTypes.bool.isRequired,
|
2022-08-20 01:22:42 +08:00
|
|
|
notify: PropTypes.func.isRequired,
|
2024-03-27 03:43:05 +08:00
|
|
|
isRTL: PropTypes.bool.isRequired,
|
|
|
|
priority: PropTypes.string.isRequired,
|
|
|
|
isOpen: PropTypes.bool.isRequired,
|
|
|
|
setIsOpen: PropTypes.func.isRequired,
|
|
|
|
AudioError: PropTypes.shape({
|
2024-07-04 19:35:01 +08:00
|
|
|
MIC_ERROR: PropTypes.shape({
|
|
|
|
UNKNOWN: PropTypes.number,
|
|
|
|
NO_SSL: PropTypes.number,
|
|
|
|
MAC_OS_BLOCK: PropTypes.number,
|
|
|
|
NO_PERMISSION: PropTypes.number,
|
|
|
|
DEVICE_NOT_FOUND: PropTypes.number,
|
|
|
|
}),
|
2024-03-27 03:43:05 +08:00
|
|
|
}).isRequired,
|
2024-04-04 22:47:01 +08:00
|
|
|
getTroubleshootingLink: PropTypes.func.isRequired,
|
2024-05-14 21:31:05 +08:00
|
|
|
away: PropTypes.bool,
|
2024-06-05 19:26:27 +08:00
|
|
|
doGUM: PropTypes.func.isRequired,
|
|
|
|
hasMicrophonePermission: PropTypes.func.isRequired,
|
|
|
|
permissionStatus: PropTypes.string,
|
|
|
|
liveChangeInputDevice: PropTypes.func.isRequired,
|
|
|
|
content: PropTypes.string,
|
|
|
|
unmuteOnExit: PropTypes.bool,
|
|
|
|
supportsTransparentListenOnly: PropTypes.bool.isRequired,
|
|
|
|
getAudioConstraints: PropTypes.func.isRequired,
|
2024-08-09 07:52:50 +08:00
|
|
|
isTranscriptionEnabled: PropTypes.bool.isRequired,
|
2017-10-23 20:41:09 +08:00
|
|
|
};
|
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
const intlMessages = defineMessages({
|
2017-09-26 04:28:36 +08:00
|
|
|
microphoneLabel: {
|
|
|
|
id: 'app.audioModal.microphoneLabel',
|
|
|
|
description: 'Join mic audio button label',
|
|
|
|
},
|
|
|
|
listenOnlyLabel: {
|
|
|
|
id: 'app.audioModal.listenOnlyLabel',
|
|
|
|
description: 'Join listen only audio button label',
|
|
|
|
},
|
2021-08-11 11:23:39 +08:00
|
|
|
listenOnlyDesc: {
|
|
|
|
id: 'app.audioModal.listenOnlyDesc',
|
|
|
|
description: 'Join listen only audio button description',
|
|
|
|
},
|
|
|
|
microphoneDesc: {
|
|
|
|
id: 'app.audioModal.microphoneDesc',
|
|
|
|
description: 'Join mic audio button description',
|
|
|
|
},
|
2017-09-26 04:28:36 +08:00
|
|
|
closeLabel: {
|
|
|
|
id: 'app.audioModal.closeLabel',
|
|
|
|
description: 'close audio modal button label',
|
|
|
|
},
|
|
|
|
audioChoiceLabel: {
|
|
|
|
id: 'app.audioModal.audioChoiceLabel',
|
|
|
|
description: 'Join audio modal title',
|
|
|
|
},
|
2018-05-25 03:39:17 +08:00
|
|
|
iOSError: {
|
|
|
|
id: 'app.audioModal.iOSBrowser',
|
|
|
|
description: 'Audio/Video Not supported warning',
|
|
|
|
},
|
|
|
|
iOSErrorDescription: {
|
|
|
|
id: 'app.audioModal.iOSErrorDescription',
|
|
|
|
description: 'Audio/Video not supported description',
|
|
|
|
},
|
|
|
|
iOSErrorRecommendation: {
|
|
|
|
id: 'app.audioModal.iOSErrorRecommendation',
|
|
|
|
description: 'Audio/Video recommended action',
|
|
|
|
},
|
2017-10-11 02:03:29 +08:00
|
|
|
echoTestTitle: {
|
|
|
|
id: 'app.audioModal.echoTestTitle',
|
|
|
|
description: 'Title for the echo test',
|
|
|
|
},
|
|
|
|
settingsTitle: {
|
2024-06-05 19:26:27 +08:00
|
|
|
id: 'app.audio.audioSettings.titleLabel',
|
2017-10-11 02:03:29 +08:00
|
|
|
description: 'Title for the audio modal',
|
|
|
|
},
|
2017-11-17 19:52:48 +08:00
|
|
|
helpTitle: {
|
|
|
|
id: 'app.audioModal.helpTitle',
|
|
|
|
description: 'Title for the audio help',
|
|
|
|
},
|
2019-04-11 04:51:06 +08:00
|
|
|
audioDialTitle: {
|
|
|
|
id: 'app.audioModal.audioDialTitle',
|
|
|
|
description: 'Title for the audio dial',
|
|
|
|
},
|
2017-10-11 02:03:29 +08:00
|
|
|
connecting: {
|
|
|
|
id: 'app.audioModal.connecting',
|
|
|
|
description: 'Message for audio connecting',
|
|
|
|
},
|
2019-05-08 21:16:00 +08:00
|
|
|
ariaModalTitle: {
|
|
|
|
id: 'app.audioModal.ariaTitle',
|
|
|
|
description: 'aria label for modal title',
|
|
|
|
},
|
2019-08-03 05:32:42 +08:00
|
|
|
autoplayPromptTitle: {
|
|
|
|
id: 'app.audioModal.autoplayBlockedDesc',
|
|
|
|
description: 'Message for autoplay audio block',
|
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
findingDevicesTitle: {
|
|
|
|
id: 'app.audio.audioSettings.findingDevicesTitle',
|
|
|
|
description: 'Message for finding audio devices',
|
|
|
|
},
|
2017-09-26 04:28:36 +08:00
|
|
|
});
|
|
|
|
|
2024-06-11 21:05:08 +08:00
|
|
|
const AudioModal = ({
|
|
|
|
forceListenOnlyAttendee,
|
|
|
|
joinFullAudioImmediately = false,
|
|
|
|
listenOnlyMode,
|
|
|
|
audioLocked,
|
|
|
|
isUsingAudio,
|
|
|
|
isListenOnly,
|
2024-06-05 19:26:27 +08:00
|
|
|
isMuted,
|
|
|
|
toggleMuteMicrophoneSystem,
|
2024-06-11 21:05:08 +08:00
|
|
|
autoplayBlocked,
|
|
|
|
closeModal,
|
|
|
|
isEchoTest,
|
|
|
|
exitAudio,
|
|
|
|
resolve = null,
|
|
|
|
leaveEchoTest,
|
|
|
|
AudioError,
|
|
|
|
joinEchoTest,
|
|
|
|
isConnecting,
|
|
|
|
localEchoEnabled,
|
|
|
|
joinListenOnly,
|
|
|
|
changeInputStream,
|
|
|
|
joinMicrophone,
|
|
|
|
intl,
|
|
|
|
isMobileNative,
|
|
|
|
formattedDialNum,
|
|
|
|
isRTL,
|
|
|
|
isConnected,
|
|
|
|
inputDeviceId = null,
|
|
|
|
outputDeviceId = null,
|
|
|
|
changeInputDevice,
|
|
|
|
changeOutputDevice,
|
|
|
|
notify,
|
|
|
|
formattedTelVoice,
|
|
|
|
handleAllowAutoplay,
|
|
|
|
isIE,
|
|
|
|
isOpen,
|
|
|
|
priority,
|
|
|
|
setIsOpen,
|
|
|
|
getTroubleshootingLink,
|
|
|
|
away = false,
|
2024-06-05 19:26:27 +08:00
|
|
|
doGUM,
|
|
|
|
getAudioConstraints,
|
|
|
|
hasMicrophonePermission,
|
|
|
|
liveChangeInputDevice,
|
|
|
|
content: initialContent,
|
|
|
|
supportsTransparentListenOnly,
|
|
|
|
unmuteOnExit = false,
|
|
|
|
permissionStatus = null,
|
2024-08-09 07:52:50 +08:00
|
|
|
isTranscriptionEnabled,
|
2024-06-11 21:05:08 +08:00
|
|
|
}) => {
|
2024-06-05 19:26:27 +08:00
|
|
|
const [content, setContent] = useState(initialContent);
|
2024-03-27 03:43:05 +08:00
|
|
|
const [hasError, setHasError] = useState(false);
|
|
|
|
const [disableActions, setDisableActions] = useState(false);
|
2024-04-17 01:33:23 +08:00
|
|
|
const [errorInfo, setErrorInfo] = useState(null);
|
2024-03-27 03:43:05 +08:00
|
|
|
const [autoplayChecked, setAutoplayChecked] = useState(false);
|
2024-06-05 19:26:27 +08:00
|
|
|
const [findingDevices, setFindingDevices] = useState(false);
|
2024-04-23 22:44:33 +08:00
|
|
|
const [setAway] = useMutation(SET_AWAY);
|
2024-04-25 04:06:53 +08:00
|
|
|
const voiceToggle = useToggleVoice();
|
2024-03-27 03:43:05 +08:00
|
|
|
|
|
|
|
const prevAutoplayBlocked = usePreviousValue(autoplayBlocked);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (prevAutoplayBlocked && !autoplayBlocked) {
|
|
|
|
setAutoplayChecked(true);
|
2021-04-30 05:03:18 +08:00
|
|
|
}
|
2024-03-27 03:43:05 +08:00
|
|
|
}, [autoplayBlocked]);
|
2020-03-03 04:49:15 +08:00
|
|
|
|
2024-04-17 01:33:23 +08:00
|
|
|
const handleJoinAudioError = (err) => {
|
2024-04-10 02:17:18 +08:00
|
|
|
const { type, errCode, errMessage } = err;
|
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
switch (type) {
|
|
|
|
case 'MEDIA_ERROR':
|
|
|
|
setContent('help');
|
2024-04-17 01:33:23 +08:00
|
|
|
setErrorInfo({
|
|
|
|
errCode,
|
|
|
|
errMessage,
|
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
setDisableActions(false);
|
|
|
|
break;
|
|
|
|
case 'CONNECTION_ERROR':
|
|
|
|
default:
|
2024-04-17 01:33:23 +08:00
|
|
|
setErrorInfo({
|
|
|
|
errCode,
|
|
|
|
errMessage: type,
|
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
setDisableActions(false);
|
|
|
|
break;
|
2017-10-10 04:48:10 +08:00
|
|
|
}
|
2024-04-10 02:17:18 +08:00
|
|
|
};
|
2018-04-24 22:52:37 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleGoToLocalEcho = () => {
|
2022-04-05 05:09:35 +08:00
|
|
|
// Simplified echo test: this will return the AudioSettings with:
|
|
|
|
// - withEcho: true
|
|
|
|
// Echo test will be local and done in the AudioSettings view instead of the
|
|
|
|
// old E2E -> yes/no -> join view
|
2024-03-27 03:43:05 +08:00
|
|
|
setContent('settings');
|
|
|
|
};
|
2022-04-05 05:09:35 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleGoToEchoTest = () => {
|
2019-10-01 22:28:06 +08:00
|
|
|
const { MIC_ERROR } = AudioError;
|
|
|
|
const noSSL = !window.location.protocol.includes('https');
|
|
|
|
|
|
|
|
if (noSSL) {
|
2024-03-27 03:43:05 +08:00
|
|
|
setContent('help');
|
2024-04-17 01:33:23 +08:00
|
|
|
setErrorInfo({
|
|
|
|
errCode: MIC_ERROR.NO_SSL,
|
|
|
|
errMessage: 'NoSSL',
|
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
return null;
|
2019-10-01 22:28:06 +08:00
|
|
|
}
|
|
|
|
|
2021-08-09 22:24:02 +08:00
|
|
|
if (disableActions && isConnecting) return null;
|
2019-11-23 05:55:26 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
if (localEchoEnabled) return handleGoToLocalEcho();
|
2022-04-05 05:09:35 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
setHasError(false);
|
|
|
|
setDisableActions(true);
|
2018-03-06 04:00:52 +08:00
|
|
|
|
2019-01-18 00:33:43 +08:00
|
|
|
return joinEchoTest().then(() => {
|
2024-03-27 03:43:05 +08:00
|
|
|
setContent('echoTest');
|
|
|
|
setDisableActions(true);
|
2018-03-02 20:01:34 +08:00
|
|
|
}).catch((err) => {
|
2024-04-17 01:33:23 +08:00
|
|
|
handleJoinAudioError(err);
|
2017-11-17 19:52:48 +08:00
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
const handleGUMFailure = (error) => {
|
|
|
|
const { MIC_ERROR } = AudioError;
|
|
|
|
|
|
|
|
logger.error({
|
|
|
|
logCode: 'audio_gum_failed',
|
|
|
|
extraInfo: {
|
|
|
|
errorMessage: error.message,
|
|
|
|
errorName: error.name,
|
|
|
|
},
|
|
|
|
}, `Audio gUM failed: ${error.name}`);
|
|
|
|
|
|
|
|
setContent('help');
|
|
|
|
setDisableActions(false);
|
|
|
|
setHasError(true);
|
|
|
|
setErrorInfo({
|
|
|
|
errCode: error?.name === 'NotAllowedError'
|
|
|
|
? MIC_ERROR.NO_PERMISSION
|
|
|
|
: 0,
|
|
|
|
errMessage: error?.name || 'NotAllowedError',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const checkMicrophonePermission = (options) => {
|
|
|
|
setFindingDevices(true);
|
|
|
|
|
|
|
|
return hasMicrophonePermission(options)
|
|
|
|
.then((hasPermission) => {
|
|
|
|
// null means undetermined, so we don't want to show the error modal
|
|
|
|
// and let downstream components figure it out
|
|
|
|
if (hasPermission === true || hasPermission === null) {
|
|
|
|
return hasPermission;
|
|
|
|
}
|
|
|
|
|
|
|
|
handleGUMFailure(new DOMException(
|
|
|
|
'Permissions API says denied',
|
|
|
|
'NotAllowedError',
|
|
|
|
));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
handleGUMFailure(error);
|
|
|
|
return null;
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
setFindingDevices(false);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleGoToAudioOptions = () => {
|
|
|
|
setContent(null);
|
|
|
|
setDisableActions(false);
|
|
|
|
};
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleGoToAudioSettings = () => {
|
|
|
|
leaveEchoTest().then(() => {
|
|
|
|
setContent('settings');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleRetryGoToEchoTest = () => {
|
|
|
|
setHasError(false);
|
|
|
|
setContent(null);
|
2024-04-17 01:33:23 +08:00
|
|
|
setErrorInfo(null);
|
2024-03-27 03:43:05 +08:00
|
|
|
|
|
|
|
return handleGoToEchoTest();
|
|
|
|
};
|
2019-11-23 05:55:26 +08:00
|
|
|
|
2024-04-23 22:44:33 +08:00
|
|
|
const disableAwayMode = () => {
|
2024-05-14 21:31:05 +08:00
|
|
|
if (!away) return;
|
|
|
|
|
2024-04-25 04:06:53 +08:00
|
|
|
muteAway(false, true, voiceToggle);
|
2024-04-23 22:44:33 +08:00
|
|
|
setAway({
|
|
|
|
variables: {
|
|
|
|
away: false,
|
|
|
|
},
|
|
|
|
});
|
2024-04-24 01:56:23 +08:00
|
|
|
VideoService.setTrackEnabled(true);
|
2024-04-23 22:44:33 +08:00
|
|
|
};
|
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleJoinListenOnly = () => {
|
2021-08-09 22:24:02 +08:00
|
|
|
if (disableActions && isConnecting) return null;
|
2019-11-23 05:55:26 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
setDisableActions(true);
|
2024-04-17 01:33:23 +08:00
|
|
|
setHasError(false);
|
|
|
|
setErrorInfo(null);
|
2019-11-23 05:55:26 +08:00
|
|
|
|
|
|
|
return joinListenOnly().then(() => {
|
2024-03-27 03:43:05 +08:00
|
|
|
setDisableActions(false);
|
2024-04-23 22:44:33 +08:00
|
|
|
disableAwayMode();
|
2019-11-23 05:55:26 +08:00
|
|
|
}).catch((err) => {
|
2024-04-17 01:33:23 +08:00
|
|
|
handleJoinAudioError(err);
|
2017-10-10 04:48:10 +08:00
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
2019-11-23 05:55:26 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const handleJoinMicrophone = () => {
|
2021-05-18 03:37:46 +08:00
|
|
|
if (disableActions && isConnecting) return;
|
2019-11-23 05:55:26 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
setHasError(false);
|
|
|
|
setDisableActions(true);
|
2024-04-17 01:33:23 +08:00
|
|
|
setErrorInfo(null);
|
2018-03-08 21:38:18 +08:00
|
|
|
|
2020-03-03 21:59:01 +08:00
|
|
|
joinMicrophone().then(() => {
|
2024-03-27 03:43:05 +08:00
|
|
|
setDisableActions(false);
|
2022-03-29 02:50:10 +08:00
|
|
|
}).catch((err) => {
|
2024-04-17 01:33:23 +08:00
|
|
|
handleJoinAudioError(err);
|
2022-03-29 02:50:10 +08:00
|
|
|
});
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
2022-03-29 02:50:10 +08:00
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
const handleAudioSettingsConfirmation = useCallback((inputStream) => {
|
2024-03-27 03:43:05 +08:00
|
|
|
// Reset the modal to a connecting state - this kind of sucks?
|
|
|
|
// prlanzarin Apr 04 2022
|
|
|
|
setContent(null);
|
|
|
|
if (inputStream) changeInputStream(inputStream);
|
2024-06-05 19:26:27 +08:00
|
|
|
|
|
|
|
if (!isConnected) {
|
|
|
|
handleJoinMicrophone();
|
|
|
|
disableAwayMode();
|
|
|
|
} else {
|
|
|
|
closeModal();
|
|
|
|
}
|
|
|
|
}, [changeInputStream, isConnected]);
|
2024-03-27 03:43:05 +08:00
|
|
|
|
2024-08-16 23:48:47 +08:00
|
|
|
const skipAudioOptions = useCallback(
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
() => !hasError && (isConnecting || (forceListenOnlyAttendee && !autoplayChecked) || !listenOnlyMode),
|
|
|
|
[hasError, isConnecting, forceListenOnlyAttendee, autoplayChecked, listenOnlyMode],
|
|
|
|
);
|
2024-03-27 03:43:05 +08:00
|
|
|
|
|
|
|
const renderAudioOptions = () => {
|
|
|
|
const hideMicrophone = forceListenOnlyAttendee || audioLocked;
|
2019-09-10 22:20:37 +08:00
|
|
|
const arrow = isRTL ? '←' : '→';
|
2019-08-29 22:26:51 +08:00
|
|
|
const dialAudioLabel = `${intl.formatMessage(intlMessages.audioDialTitle)} ${arrow}`;
|
2019-08-27 04:47:54 +08:00
|
|
|
|
2017-09-26 04:28:36 +08:00
|
|
|
return (
|
2019-03-29 05:53:42 +08:00
|
|
|
<div>
|
2022-02-09 23:52:42 +08:00
|
|
|
<Styled.AudioOptions data-test="audioModalOptions">
|
2024-03-27 03:43:05 +08:00
|
|
|
{!hideMicrophone && !isMobileNative && (
|
|
|
|
<>
|
|
|
|
<Styled.AudioModalButton
|
|
|
|
label={intl.formatMessage(intlMessages.microphoneLabel)}
|
|
|
|
data-test="microphoneBtn"
|
|
|
|
aria-describedby="mic-description"
|
|
|
|
icon="unmute"
|
|
|
|
circle
|
|
|
|
size="jumbo"
|
|
|
|
disabled={audioLocked}
|
|
|
|
onClick={
|
|
|
|
joinFullAudioImmediately
|
|
|
|
? handleJoinMicrophone
|
|
|
|
: handleGoToEchoTest
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<span className="sr-only" id="mic-description">
|
|
|
|
{intl.formatMessage(intlMessages.microphoneDesc)}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{listenOnlyMode && (
|
|
|
|
<>
|
|
|
|
<Styled.AudioModalButton
|
|
|
|
label={intl.formatMessage(intlMessages.listenOnlyLabel)}
|
|
|
|
data-test="listenOnlyBtn"
|
|
|
|
aria-describedby="listenOnly-description"
|
|
|
|
icon="listen"
|
|
|
|
circle
|
|
|
|
size="jumbo"
|
|
|
|
onClick={handleJoinListenOnly}
|
|
|
|
/>
|
|
|
|
<span className="sr-only" id="listenOnly-description">
|
|
|
|
{intl.formatMessage(intlMessages.listenOnlyDesc)}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2021-11-09 21:22:59 +08:00
|
|
|
</Styled.AudioOptions>
|
2019-04-17 01:04:23 +08:00
|
|
|
{formattedDialNum ? (
|
2021-11-09 21:22:59 +08:00
|
|
|
<Styled.AudioDial
|
2019-08-27 04:47:54 +08:00
|
|
|
label={dialAudioLabel}
|
2019-04-11 04:51:06 +08:00
|
|
|
size="md"
|
2022-08-05 01:17:45 +08:00
|
|
|
color="secondary"
|
2019-04-11 04:51:06 +08:00
|
|
|
onClick={() => {
|
2024-03-27 03:43:05 +08:00
|
|
|
setContent('audioDial');
|
2019-04-11 04:51:06 +08:00
|
|
|
}}
|
|
|
|
/>
|
2019-08-29 22:26:51 +08:00
|
|
|
) : null}
|
2024-08-09 07:52:50 +08:00
|
|
|
{joinFullAudioImmediately && <AudioCaptionsSelectContainer />}
|
2019-03-29 05:53:42 +08:00
|
|
|
</div>
|
2017-09-26 04:28:36 +08:00
|
|
|
);
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
2017-09-26 04:28:36 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const renderEchoTest = () => (
|
|
|
|
<EchoTest
|
|
|
|
handleNo={handleGoToAudioSettings}
|
|
|
|
handleYes={handleJoinMicrophone}
|
|
|
|
/>
|
|
|
|
);
|
2017-10-05 04:49:11 +08:00
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
const handleBack = useCallback(() => {
|
2024-08-16 23:48:47 +08:00
|
|
|
// If audio is active, audio options are flagged to be skipped (see skipAudioOptions)
|
|
|
|
// or listen only mode is deactivated (which means there are no actual options
|
|
|
|
// in the base modal), clicking back on any of the sub-modals should close the base modal
|
|
|
|
if (isConnecting
|
|
|
|
|| isConnected
|
|
|
|
|| skipAudioOptions()) {
|
2024-06-05 19:26:27 +08:00
|
|
|
closeModal();
|
|
|
|
} else {
|
|
|
|
handleGoToAudioOptions();
|
|
|
|
}
|
2024-08-16 23:48:47 +08:00
|
|
|
}, [isConnecting, isConnected, skipAudioOptions, listenOnlyMode]);
|
2024-06-05 19:26:27 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const renderAudioSettings = () => {
|
2024-06-05 19:26:27 +08:00
|
|
|
const { animations } = getSettingsSingletonInstance().application;
|
2022-04-12 04:18:43 +08:00
|
|
|
const confirmationCallback = !localEchoEnabled
|
2024-03-27 03:43:05 +08:00
|
|
|
? handleRetryGoToEchoTest
|
2024-06-05 19:26:27 +08:00
|
|
|
: handleAudioSettingsConfirmation;
|
2022-04-05 05:09:35 +08:00
|
|
|
|
2017-10-05 04:49:11 +08:00
|
|
|
return (
|
|
|
|
<AudioSettings
|
2024-06-05 19:26:27 +08:00
|
|
|
animations={animations}
|
|
|
|
handleBack={handleBack}
|
2022-04-05 05:09:35 +08:00
|
|
|
handleConfirmation={confirmationCallback}
|
|
|
|
handleGUMFailure={handleGUMFailure}
|
2019-01-18 00:33:43 +08:00
|
|
|
joinEchoTest={joinEchoTest}
|
|
|
|
changeInputDevice={changeInputDevice}
|
2024-06-05 19:26:27 +08:00
|
|
|
liveChangeInputDevice={liveChangeInputDevice}
|
2019-01-18 00:33:43 +08:00
|
|
|
changeOutputDevice={changeOutputDevice}
|
2017-10-05 04:49:11 +08:00
|
|
|
isConnecting={isConnecting}
|
|
|
|
isConnected={isConnected}
|
2024-06-05 19:26:27 +08:00
|
|
|
isMuted={isMuted}
|
|
|
|
toggleMuteMicrophoneSystem={toggleMuteMicrophoneSystem}
|
2017-10-05 04:49:11 +08:00
|
|
|
inputDeviceId={inputDeviceId}
|
2017-10-11 02:03:29 +08:00
|
|
|
outputDeviceId={outputDeviceId}
|
2022-04-12 04:18:43 +08:00
|
|
|
withEcho={localEchoEnabled}
|
2024-08-09 07:52:50 +08:00
|
|
|
produceStreams
|
2022-08-20 01:22:42 +08:00
|
|
|
notify={notify}
|
2024-06-05 19:26:27 +08:00
|
|
|
unmuteOnExit={unmuteOnExit}
|
|
|
|
doGUM={doGUM}
|
|
|
|
getAudioConstraints={getAudioConstraints}
|
|
|
|
checkMicrophonePermission={checkMicrophonePermission}
|
|
|
|
supportsTransparentListenOnly={supportsTransparentListenOnly}
|
|
|
|
toggleVoice={voiceToggle}
|
2024-08-09 07:52:50 +08:00
|
|
|
permissionStatus={permissionStatus}
|
|
|
|
isTranscriptionEnabled={isTranscriptionEnabled}
|
2024-08-16 23:48:47 +08:00
|
|
|
skipAudioOptions={skipAudioOptions}
|
2017-10-05 04:49:11 +08:00
|
|
|
/>
|
2017-10-11 02:03:29 +08:00
|
|
|
);
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
2019-09-30 22:54:34 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
const renderHelp = () => {
|
2019-09-30 22:54:34 +08:00
|
|
|
const audioErr = {
|
|
|
|
...AudioError,
|
2024-04-17 01:33:23 +08:00
|
|
|
code: errorInfo?.errCode,
|
|
|
|
message: errorInfo?.errMessage,
|
2019-09-30 22:54:34 +08:00
|
|
|
};
|
2019-09-27 21:52:29 +08:00
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
const _joinListenOnly = () => {
|
|
|
|
// Erase the content state so that the modal transitions to the connecting
|
|
|
|
// state if the user chooses listen only
|
|
|
|
setContent(null);
|
|
|
|
handleJoinListenOnly();
|
|
|
|
};
|
|
|
|
|
2017-11-17 19:52:48 +08:00
|
|
|
return (
|
|
|
|
<Help
|
2024-06-05 19:26:27 +08:00
|
|
|
isConnected={isConnected}
|
|
|
|
handleBack={handleBack}
|
|
|
|
handleJoinListenOnly={_joinListenOnly}
|
|
|
|
handleRetryMic={handleGoToAudioSettings}
|
2019-09-30 22:54:34 +08:00
|
|
|
audioErr={audioErr}
|
2024-04-17 01:33:23 +08:00
|
|
|
isListenOnly={isListenOnly}
|
|
|
|
troubleshootingLink={getTroubleshootingLink(errorInfo?.errCode)}
|
2017-11-17 19:52:48 +08:00
|
|
|
/>
|
|
|
|
);
|
2024-03-27 03:43:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const renderAudioDial = () => (
|
|
|
|
<AudioDial
|
|
|
|
formattedDialNum={formattedDialNum}
|
|
|
|
telVoice={formattedTelVoice}
|
|
|
|
handleBack={handleGoToAudioOptions}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderAutoplayOverlay = () => (
|
|
|
|
<AudioAutoplayPrompt
|
|
|
|
handleAllowAutoplay={handleAllowAutoplay}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const contents = {
|
|
|
|
echoTest: {
|
|
|
|
title: intlMessages.echoTestTitle,
|
|
|
|
component: renderEchoTest,
|
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
title: intlMessages.settingsTitle,
|
|
|
|
component: renderAudioSettings,
|
|
|
|
},
|
|
|
|
help: {
|
|
|
|
title: intlMessages.helpTitle,
|
|
|
|
component: renderHelp,
|
|
|
|
},
|
|
|
|
audioDial: {
|
|
|
|
title: intlMessages.audioDialTitle,
|
|
|
|
component: renderAudioDial,
|
|
|
|
},
|
|
|
|
autoplayBlocked: {
|
|
|
|
title: intlMessages.autoplayPromptTitle,
|
|
|
|
component: renderAutoplayOverlay,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderContent = () => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const { animations } = getSettingsSingletonInstance().application;
|
2017-11-17 19:52:48 +08:00
|
|
|
|
2024-08-16 23:48:47 +08:00
|
|
|
if (content == null) {
|
|
|
|
if (findingDevices) {
|
|
|
|
return (
|
|
|
|
<Styled.Connecting role="alert">
|
|
|
|
<span data-test="findingDevicesLabel">
|
|
|
|
{intl.formatMessage(intlMessages.findingDevicesTitle)}
|
|
|
|
</span>
|
|
|
|
<Styled.ConnectingAnimation animations={animations} />
|
|
|
|
</Styled.Connecting>
|
|
|
|
);
|
|
|
|
}
|
2024-06-05 19:26:27 +08:00
|
|
|
|
2024-08-16 23:48:47 +08:00
|
|
|
if (skipAudioOptions()) {
|
|
|
|
return (
|
|
|
|
<Styled.Connecting role="alert">
|
|
|
|
<span data-test={!isEchoTest ? 'establishingAudioLabel' : 'connectingToEchoTest'}>
|
|
|
|
{intl.formatMessage(intlMessages.connecting)}
|
|
|
|
</span>
|
|
|
|
<Styled.ConnectingAnimation animations={animations} />
|
|
|
|
</Styled.Connecting>
|
|
|
|
);
|
|
|
|
}
|
2024-03-27 03:43:05 +08:00
|
|
|
}
|
2024-06-05 19:26:27 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
return content ? contents[content].component() : renderAudioOptions();
|
|
|
|
};
|
2019-04-11 04:51:06 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
useEffect(() => {
|
|
|
|
if (!isUsingAudio) {
|
|
|
|
if (forceListenOnlyAttendee || audioLocked) {
|
|
|
|
handleJoinListenOnly();
|
2024-06-05 19:26:27 +08:00
|
|
|
} else if (!listenOnlyMode) {
|
|
|
|
if (joinFullAudioImmediately) {
|
|
|
|
checkMicrophonePermission({ doGUM: true, permissionStatus })
|
|
|
|
.then((hasPermission) => {
|
|
|
|
// No permission - let the Help screen be shown as it's triggered
|
|
|
|
// by the checkMicrophonePermission function
|
|
|
|
if (hasPermission === false) return;
|
|
|
|
|
|
|
|
// Permission is granted or undetermined, so we can proceed
|
|
|
|
handleJoinMicrophone();
|
|
|
|
});
|
|
|
|
} else {
|
fix(audio): prevent permission check loop in Safari
Safari may enter a microphone permission check loop due to buggy behavior
in the Permissions API. When permission isn't permanently denied, gUM
requests fail with a NotAllowedError for a few seconds. During this time,
the permission state remains 'prompt' instead of transitioning to 'denied'
and back to 'prompt' after the timeout.
This leads to an issue where, on retrying while in 'prompt' + blocked,
the client loops through gUM checks via: 1) checking permission in the API,
2) receiving 'prompt', so trying gUM, 3) gUM fails, 4) returning to the
modal and checking permission again because the API still says 'prompt'.
Additionally, the `isUsingAudio` flag incorrectly counts the local echo
test/audio settings modal as "using audio," which toggles the flag on/off,
triggering the useEffect that causes the loop more frequently.
To fix this, remove the unnecessary AudioModal permission check that
causes the loop. Also, exclude "isEchoTest" from the `isUsingAudio` flag.
2024-08-21 03:09:59 +08:00
|
|
|
// No need to check for permission here since the AudioSettings
|
|
|
|
// component will handle it
|
|
|
|
handleGoToEchoTest();
|
2024-06-05 19:26:27 +08:00
|
|
|
}
|
2024-03-27 03:43:05 +08:00
|
|
|
}
|
|
|
|
}
|
2024-06-13 05:24:13 +08:00
|
|
|
}, [
|
|
|
|
audioLocked,
|
|
|
|
isUsingAudio,
|
|
|
|
forceListenOnlyAttendee,
|
|
|
|
joinFullAudioImmediately,
|
|
|
|
listenOnlyMode,
|
|
|
|
]);
|
2017-10-11 02:03:29 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
useEffect(() => {
|
|
|
|
if (autoplayBlocked) {
|
|
|
|
setContent('autoplayBlocked');
|
|
|
|
} else if (prevAutoplayBlocked) {
|
|
|
|
closeModal();
|
|
|
|
}
|
|
|
|
}, [autoplayBlocked]);
|
2017-10-11 02:03:29 +08:00
|
|
|
|
2024-03-27 03:43:05 +08:00
|
|
|
useEffect(() => () => {
|
|
|
|
if (isEchoTest) {
|
|
|
|
exitAudio();
|
|
|
|
}
|
|
|
|
if (resolve) resolve();
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('audioModalIsOpen', false);
|
2024-03-27 03:43:05 +08:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
let title = content
|
|
|
|
? intl.formatMessage(contents[content].title)
|
|
|
|
: intl.formatMessage(intlMessages.audioChoiceLabel);
|
2024-08-16 23:48:47 +08:00
|
|
|
title = (!skipAudioOptions() && !findingDevices) || content
|
2024-08-15 11:30:18 +08:00
|
|
|
? title
|
|
|
|
: null;
|
2024-03-27 03:43:05 +08:00
|
|
|
|
|
|
|
return (
|
2024-08-28 00:39:11 +08:00
|
|
|
<Styled.Background isBlurred={Session.getItem('audioModalIsOpen')}>
|
|
|
|
<Styled.AudioModal
|
|
|
|
modalName="AUDIO"
|
|
|
|
onRequestClose={closeModal}
|
|
|
|
data-test="audioModal"
|
|
|
|
contentLabel={intl.formatMessage(intlMessages.ariaModalTitle)}
|
|
|
|
title={title}
|
|
|
|
{...{
|
|
|
|
setIsOpen,
|
|
|
|
isOpen,
|
|
|
|
priority,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{isIE ? (
|
|
|
|
<Styled.BrowserWarning>
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.audioModal.unsupportedBrowserLabel"
|
|
|
|
description="Warning when someone joins with a browser that isn't supported"
|
|
|
|
values={{
|
|
|
|
0: <a href="https://www.google.com/chrome/">Chrome</a>,
|
|
|
|
1: <a href="https://getfirefox.com">Firefox</a>,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Styled.BrowserWarning>
|
|
|
|
) : null}
|
|
|
|
<Styled.Content>
|
|
|
|
{renderContent()}
|
|
|
|
</Styled.Content>
|
|
|
|
</Styled.AudioModal>
|
|
|
|
</Styled.Background>
|
2024-03-27 03:43:05 +08:00
|
|
|
);
|
|
|
|
};
|
2017-09-26 04:28:36 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
AudioModal.propTypes = propTypes;
|
|
|
|
|
2017-09-26 04:28:36 +08:00
|
|
|
export default injectIntl(AudioModal);
|