[RN] Try to create local tracks when unmuting, if track is missing
This is only desired when the unmuting action took place due to a manual user intervention or the audio-only mode being disengaged.
This commit is contained in:
parent
28b4595561
commit
3102ea6818
|
@ -243,7 +243,11 @@ function _setAudioOnly({ dispatch, getState }, next, action) {
|
||||||
dispatch(setLastN(audioOnly ? 0 : undefined));
|
dispatch(setLastN(audioOnly ? 0 : undefined));
|
||||||
|
|
||||||
// Mute/unmute the local video.
|
// Mute/unmute the local video.
|
||||||
dispatch(setVideoMuted(audioOnly, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY));
|
dispatch(
|
||||||
|
setVideoMuted(
|
||||||
|
audioOnly,
|
||||||
|
VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY,
|
||||||
|
/* ensureTrack */ true));
|
||||||
|
|
||||||
if (typeof APP !== 'undefined') {
|
if (typeof APP !== 'undefined') {
|
||||||
// TODO This should be a temporary solution that lasts only until
|
// TODO This should be a temporary solution that lasts only until
|
||||||
|
|
|
@ -34,14 +34,18 @@ export function setAudioAvailable(available: boolean) {
|
||||||
*
|
*
|
||||||
* @param {boolean} muted - True if the local audio is to be muted or false if
|
* @param {boolean} muted - True if the local audio is to be muted or false if
|
||||||
* the local audio is to be unmuted.
|
* the local audio is to be unmuted.
|
||||||
|
* @param {boolean} ensureTrack - True if we want to ensure that a new track is
|
||||||
|
* created if missing.
|
||||||
* @returns {{
|
* @returns {{
|
||||||
* type: SET_AUDIO_MUTED,
|
* type: SET_AUDIO_MUTED,
|
||||||
|
* ensureTrack: boolean,
|
||||||
* muted: boolean
|
* muted: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setAudioMuted(muted: boolean) {
|
export function setAudioMuted(muted: boolean, ensureTrack: boolean = false) {
|
||||||
return {
|
return {
|
||||||
type: SET_AUDIO_MUTED,
|
type: SET_AUDIO_MUTED,
|
||||||
|
ensureTrack,
|
||||||
muted
|
muted
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -86,11 +90,14 @@ export function setVideoAvailable(available: boolean) {
|
||||||
* the local video is to be unmuted.
|
* the local video is to be unmuted.
|
||||||
* @param {number} authority - The {@link VIDEO_MUTISM_AUTHORITY} which is
|
* @param {number} authority - The {@link VIDEO_MUTISM_AUTHORITY} which is
|
||||||
* muting/unmuting the local video.
|
* muting/unmuting the local video.
|
||||||
|
* @param {boolean} ensureTrack - True if we want to ensure that a new track is
|
||||||
|
* created if missing.
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function setVideoMuted(
|
export function setVideoMuted(
|
||||||
muted: boolean,
|
muted: boolean,
|
||||||
authority: number = VIDEO_MUTISM_AUTHORITY.USER) {
|
authority: number = VIDEO_MUTISM_AUTHORITY.USER,
|
||||||
|
ensureTrack: boolean = false) {
|
||||||
return (dispatch: Dispatch<*>, getState: Function) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const oldValue = getState()['features/base/media'].video.muted;
|
const oldValue = getState()['features/base/media'].video.muted;
|
||||||
|
|
||||||
|
@ -99,6 +106,7 @@ export function setVideoMuted(
|
||||||
|
|
||||||
return dispatch({
|
return dispatch({
|
||||||
type: SET_VIDEO_MUTED,
|
type: SET_VIDEO_MUTED,
|
||||||
|
ensureTrack,
|
||||||
muted: newValue
|
muted: newValue
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
} from '../media';
|
} from '../media';
|
||||||
import { MiddlewareRegistry } from '../redux';
|
import { MiddlewareRegistry } from '../redux';
|
||||||
|
|
||||||
|
import { createLocalTracksA } from './actions';
|
||||||
import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
|
import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
|
||||||
import { getLocalTrack, setTrackMuted } from './functions';
|
import { getLocalTrack, setTrackMuted } from './functions';
|
||||||
|
|
||||||
|
@ -153,8 +154,14 @@ function _getLocalTrack({ getState }, mediaType: MEDIA_TYPE) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _setMuted(store, { muted }, mediaType: MEDIA_TYPE) {
|
function _setMuted(store, { ensureTrack, muted }, mediaType: MEDIA_TYPE) {
|
||||||
const localTrack = _getLocalTrack(store, mediaType);
|
const localTrack = _getLocalTrack(store, mediaType);
|
||||||
|
|
||||||
localTrack && setTrackMuted(localTrack.jitsiTrack, muted);
|
if (localTrack) {
|
||||||
|
setTrackMuted(localTrack.jitsiTrack, muted);
|
||||||
|
} else if (!muted && ensureTrack && typeof APP === 'undefined') {
|
||||||
|
// FIXME: This only runs on mobile now because web has its own way of
|
||||||
|
// creating local tracks. Adjust the check once they are unified.
|
||||||
|
store.dispatch(createLocalTracksA({ devices: [ mediaType ] }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ import {
|
||||||
MEDIA_TYPE,
|
MEDIA_TYPE,
|
||||||
setAudioMuted,
|
setAudioMuted,
|
||||||
setVideoMuted,
|
setVideoMuted,
|
||||||
toggleCameraFacingMode
|
toggleCameraFacingMode,
|
||||||
|
VIDEO_MUTISM_AUTHORITY
|
||||||
} from '../../base/media';
|
} from '../../base/media';
|
||||||
import { Container } from '../../base/react';
|
import { Container } from '../../base/react';
|
||||||
import { ColorPalette } from '../../base/styles';
|
import { ColorPalette } from '../../base/styles';
|
||||||
|
@ -167,7 +168,11 @@ class Toolbox extends Component {
|
||||||
// sets the state of base/media. Whether the user's intention will turn
|
// sets the state of base/media. Whether the user's intention will turn
|
||||||
// into reality is a whole different story which is of no concern to the
|
// into reality is a whole different story which is of no concern to the
|
||||||
// tapping.
|
// tapping.
|
||||||
this.props.dispatch(setAudioMuted(!this.props._audioMuted));
|
this.props.dispatch(
|
||||||
|
setAudioMuted(
|
||||||
|
!this.props._audioMuted,
|
||||||
|
VIDEO_MUTISM_AUTHORITY.USER,
|
||||||
|
/* ensureTrack */ true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +187,11 @@ class Toolbox extends Component {
|
||||||
// sets the state of base/media. Whether the user's intention will turn
|
// sets the state of base/media. Whether the user's intention will turn
|
||||||
// into reality is a whole different story which is of no concern to the
|
// into reality is a whole different story which is of no concern to the
|
||||||
// tapping.
|
// tapping.
|
||||||
this.props.dispatch(setVideoMuted(!this.props._videoMuted));
|
this.props.dispatch(
|
||||||
|
setVideoMuted(
|
||||||
|
!this.props._videoMuted,
|
||||||
|
VIDEO_MUTISM_AUTHORITY.USER,
|
||||||
|
/* ensureTrack */ true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue