mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 17:07:48 +00:00
The behavior can be triggered with the toggleAudioOnly action, which is currently fired with a button. The following aspects of the conference will change when in audio only mode: - local video is muted - last N is set to 0 (effectively muting remote video) - full-screen mode is exited - audio mode is set to "audio chat" (default output is the earpiece) - the wake lock is disengaged One aspect not handled in this patch is disabling the video mute button while in audio only mode. The user should not be able to turn back video on in that case.
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
/* @flow */
|
|
|
|
import { NativeModules } from 'react-native';
|
|
|
|
import { APP_WILL_MOUNT } from '../../app';
|
|
import {
|
|
CONFERENCE_FAILED,
|
|
CONFERENCE_LEFT,
|
|
CONFERENCE_WILL_JOIN,
|
|
SET_AUDIO_ONLY
|
|
} from '../../base/conference';
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
/**
|
|
* Middleware that captures conference actions and sets the correct audio mode
|
|
* based on the type of conference. Audio-only conferences don't use the speaker
|
|
* by default, and video conferences do.
|
|
*
|
|
* @param {Store} store - Redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
const AudioMode = NativeModules.AudioMode;
|
|
|
|
if (AudioMode) {
|
|
let mode;
|
|
|
|
switch (action.type) {
|
|
case APP_WILL_MOUNT:
|
|
case CONFERENCE_FAILED:
|
|
case CONFERENCE_LEFT:
|
|
mode = AudioMode.DEFAULT;
|
|
break;
|
|
|
|
case CONFERENCE_WILL_JOIN: {
|
|
const { audioOnly } = store.getState()['features/base/conference'];
|
|
|
|
mode = audioOnly ? AudioMode.AUDIO_CALL : AudioMode.VIDEO_CALL;
|
|
break;
|
|
}
|
|
|
|
case SET_AUDIO_ONLY:
|
|
mode
|
|
= action.audioOnly
|
|
? AudioMode.AUDIO_CALL
|
|
: AudioMode.VIDEO_CALL;
|
|
break;
|
|
|
|
default:
|
|
mode = null;
|
|
break;
|
|
}
|
|
|
|
if (mode !== null) {
|
|
AudioMode.setMode(mode)
|
|
.catch(err =>
|
|
console.error(
|
|
`Failed to set audio mode ${String(mode)}: `
|
|
+ `${err}`));
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
});
|