mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 13:17:46 +00:00
* fix(device-selection) Enable device selection on mobile Safari. With https://bugs.webkit.org/show_bug.cgi?id=179363 being fixed, we should now be able to switch between devices in call. Also, before the webkit fix, we were able to continue to use the old track when a new track was created for preview in device settings before joining the call. This doesn't work anymore after the fix. Therefore, always replace the track in redux even if the selected device hasn't changed. Depends on https://github.com/jitsi/lib-jitsi-meet/pull/1993. * chore(deps): update lib-jitsi-meet@latest.
73 lines
2.9 KiB
JavaScript
73 lines
2.9 KiB
JavaScript
import { createDeviceChangedEvent, sendAnalytics } from '../analytics';
|
|
import {
|
|
getDeviceLabelById,
|
|
setAudioInputDevice,
|
|
setAudioOutputDeviceId,
|
|
setVideoInputDevice
|
|
} from '../base/devices';
|
|
import { isIosMobileBrowser } from '../base/environment/utils';
|
|
import { browser } from '../base/lib-jitsi-meet';
|
|
import { updateSettings } from '../base/settings';
|
|
|
|
import { getDeviceSelectionDialogProps } from './functions';
|
|
import logger from './logger';
|
|
|
|
/**
|
|
* Submits the settings related to device selection.
|
|
*
|
|
* @param {Object} newState - The new settings.
|
|
* @returns {Function}
|
|
*/
|
|
export function submitDeviceSelectionTab(newState) {
|
|
// Always use the new track for mobile Safari because of https://bugs.webkit.org/show_bug.cgi?id=179363#c30. The
|
|
// old track is stopped by the browser when a new track is created for preview so it needs to be replaced even if
|
|
// the device selection doesn't change.
|
|
const replaceTrackAlways = isIosMobileBrowser() && browser.isVersionGreaterThan('15.3');
|
|
|
|
return (dispatch, getState) => {
|
|
const currentState = getDeviceSelectionDialogProps(getState());
|
|
|
|
if ((newState.selectedVideoInputId && (newState.selectedVideoInputId !== currentState.selectedVideoInputId))
|
|
|| replaceTrackAlways) {
|
|
dispatch(updateSettings({
|
|
userSelectedCameraDeviceId: newState.selectedVideoInputId,
|
|
userSelectedCameraDeviceLabel:
|
|
getDeviceLabelById(getState(), newState.selectedVideoInputId, 'videoInput')
|
|
}));
|
|
|
|
dispatch(setVideoInputDevice(newState.selectedVideoInputId));
|
|
}
|
|
|
|
if ((newState.selectedAudioInputId && newState.selectedAudioInputId !== currentState.selectedAudioInputId)
|
|
|| replaceTrackAlways) {
|
|
dispatch(updateSettings({
|
|
userSelectedMicDeviceId: newState.selectedAudioInputId,
|
|
userSelectedMicDeviceLabel:
|
|
getDeviceLabelById(getState(), newState.selectedAudioInputId, 'audioInput')
|
|
}));
|
|
|
|
dispatch(setAudioInputDevice(newState.selectedAudioInputId));
|
|
}
|
|
|
|
if (newState.selectedAudioOutputId
|
|
&& newState.selectedAudioOutputId
|
|
!== currentState.selectedAudioOutputId) {
|
|
sendAnalytics(createDeviceChangedEvent('audio', 'output'));
|
|
|
|
setAudioOutputDeviceId(
|
|
newState.selectedAudioOutputId,
|
|
dispatch,
|
|
true,
|
|
getDeviceLabelById(getState(), newState.selectedAudioOutputId, 'audioOutput'))
|
|
.then(() => logger.log('changed audio output device'))
|
|
.catch(err => {
|
|
logger.warn(
|
|
'Failed to change audio output device.',
|
|
'Default or previously set audio output device will',
|
|
' be used instead.',
|
|
err);
|
|
});
|
|
}
|
|
};
|
|
}
|