[RN] Add audio only mode for conferences

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.
This commit is contained in:
Saúl Ibarra Corretgé
2017-03-29 14:07:05 +02:00
committed by Lyubo Marinov
parent 4ec4c45a90
commit 8fe3dce649
9 changed files with 235 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { View } from 'react-native';
import { connect } from 'react-redux';
import { toggleAudioOnly } from '../../base/conference';
import { MEDIA_TYPE, toggleCameraFacingMode } from '../../base/media';
import { Container } from '../../base/react';
import { ColorPalette } from '../../base/styles';
@@ -40,7 +41,7 @@ class Toolbox extends Component {
_onHangup: React.PropTypes.func,
/**
* Handler for room locking.
* Sets the lock i.e. password protection of the conference/room.
*/
_onRoomLock: React.PropTypes.func,
@@ -50,7 +51,13 @@ class Toolbox extends Component {
_onToggleAudio: React.PropTypes.func,
/**
* Handler for toggling camera facing mode.
* Toggles the audio-only flag of the conference.
*/
_onToggleAudioOnly: React.PropTypes.func,
/**
* Switches between the front/user-facing and back/environment-facing
* cameras.
*/
_onToggleCameraFacingMode: React.PropTypes.func,
@@ -198,6 +205,12 @@ class Toolbox extends Component {
onClick = { this.props._onRoomLock }
style = { style }
underlayColor = { underlayColor } />
<ToolbarButton
iconName = 'star'
iconStyle = { iconStyle }
onClick = { this.props._onToggleAudioOnly }
style = { style }
underlayColor = { underlayColor } />
</View>
);
@@ -224,6 +237,7 @@ Object.assign(Toolbox.prototype, {
* @param {Function} dispatch - Redux action dispatcher.
* @returns {{
* _onRoomLock: Function,
* _onToggleAudioOnly: Function,
* _onToggleCameraFacingMode: Function,
* }}
* @private
@@ -233,11 +247,10 @@ function _mapDispatchToProps(dispatch) {
...abstractMapDispatchToProps(dispatch),
/**
* Dispatches an action to set the lock i.e. password protection of the
* conference/room.
* Sets the lock i.e. password protection of the conference/room.
*
* @private
* @returns {Object} - Dispatched action.
* @returns {Object} Dispatched action.
* @type {Function}
*/
_onRoomLock() {
@@ -245,11 +258,22 @@ function _mapDispatchToProps(dispatch) {
},
/**
* Switches between the front/user-facing and rear/environment-facing
* Toggles the audio-only flag of the conference.
*
* @private
* @returns {Object} Dispatched action.
* @type {Function}
*/
_onToggleAudioOnly() {
return dispatch(toggleAudioOnly());
},
/**
* Switches between the front/user-facing and back/environment-facing
* cameras.
*
* @private
* @returns {Object} - Dispatched action.
* @returns {Object} Dispatched action.
* @type {Function}
*/
_onToggleCameraFacingMode() {