mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-12 06:42:29 +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.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import KeepAwake from 'react-native-keep-awake';
|
|
|
|
import {
|
|
CONFERENCE_FAILED,
|
|
CONFERENCE_JOINED,
|
|
CONFERENCE_LEFT,
|
|
SET_AUDIO_ONLY
|
|
} from '../../base/conference';
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
/**
|
|
* Middleware that captures conference actions and activates or deactivates the
|
|
* wake lock accordingly. If the wake lock is active, it will prevent the screen
|
|
* from dimming.
|
|
*
|
|
* @param {Store} store - Redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
switch (action.type) {
|
|
case CONFERENCE_JOINED: {
|
|
const { audioOnly } = store.getState()['features/base/conference'];
|
|
|
|
_setWakeLock(!audioOnly);
|
|
break;
|
|
}
|
|
|
|
case CONFERENCE_FAILED:
|
|
case CONFERENCE_LEFT:
|
|
_setWakeLock(false);
|
|
break;
|
|
|
|
case SET_AUDIO_ONLY:
|
|
_setWakeLock(!action.audioOnly);
|
|
break;
|
|
}
|
|
|
|
return next(action);
|
|
});
|
|
|
|
/**
|
|
* Activates/deactivates the wake lock. If the wake lock is active, it will
|
|
* prevent the screen from dimming.
|
|
*
|
|
* @param {boolean} wakeLock - True to active the wake lock or false to
|
|
* deactivate it.
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
function _setWakeLock(wakeLock) {
|
|
if (wakeLock) {
|
|
KeepAwake.activate();
|
|
} else {
|
|
KeepAwake.deactivate();
|
|
}
|
|
}
|