feat(external_api): Add command for toggling camera on mobile web

pull/8880/head
Mihai-Andrei Uscat 4 years ago committed by GitHub
parent 2c9078985f
commit 1ad40de487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/API/API.js
  2. 1
      modules/API/external/external_api.js
  3. 15
      react/features/base/tracks/functions.js
  4. 6
      react/features/toolbox/components/web/ToggleCameraButton.js

@ -23,6 +23,7 @@ import {
pinParticipant,
kickParticipant
} from '../../react/features/base/participants';
import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
import { setPrivateMessageRecipient } from '../../react/features/chat/actions';
import { openChat } from '../../react/features/chat/actions.web';
import {
@ -169,6 +170,13 @@ function initCommands() {
sendAnalytics(createApiEvent('film.strip.toggled'));
APP.UI.toggleFilmstrip();
},
'toggle-camera': () => {
if (!isToggleCameraEnabled(APP.store.getState())) {
return;
}
APP.store.dispatch(toggleCamera());
},
'toggle-chat': () => {
sendAnalytics(createApiEvent('chat.toggled'));
APP.UI.toggleChat();

@ -51,6 +51,7 @@ const commands = {
subject: 'subject',
submitFeedback: 'submit-feedback',
toggleAudio: 'toggle-audio',
toggleCamera: 'toggle-camera',
toggleChat: 'toggle-chat',
toggleFilmStrip: 'toggle-film-strip',
toggleRaiseHand: 'toggle-raise-hand',

@ -1,7 +1,9 @@
/* global APP */
import { isMobileBrowser } from '../environment/utils';
import JitsiMeetJS, { JitsiTrackErrors, browser } from '../lib-jitsi-meet';
import { MEDIA_TYPE, VIDEO_TYPE, setAudioMuted } from '../media';
import { toState } from '../redux';
import {
getUserSelectedCameraDeviceId,
getUserSelectedMicDeviceId
@ -475,3 +477,16 @@ export function setTrackMuted(track, muted) {
}
});
}
/**
* Determines whether toggle camera should be enabled or not.
*
* @param {Function|Object} stateful - The redux store or {@code getState} function.
* @returns {boolean} - Whether toggle camera should be enabled.
*/
export function isToggleCameraEnabled(stateful) {
const state = toState(stateful);
const { videoInput } = state['features/base/devices'].availableDevices;
return isMobileBrowser() && videoInput.length > 1;
}

@ -1,11 +1,10 @@
// @flow
import { isMobileBrowser } from '../../../base/environment/utils';
import { translate } from '../../../base/i18n';
import { IconCameraRefresh } from '../../../base/icons';
import { connect } from '../../../base/redux';
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
import { isLocalCameraTrackMuted, toggleCamera } from '../../../base/tracks';
import { isLocalCameraTrackMuted, isToggleCameraEnabled, toggleCamera } from '../../../base/tracks';
/**
* The type of the React {@code Component} props of {@link ToggleCameraButton}.
@ -65,12 +64,11 @@ class ToggleCameraButton extends AbstractButton<Props, any> {
function mapStateToProps(state): Object {
const { enabled: audioOnly } = state['features/base/audio-only'];
const tracks = state['features/base/tracks'];
const { videoInput } = state['features/base/devices'].availableDevices;
return {
_audioOnly: Boolean(audioOnly),
_videoMuted: isLocalCameraTrackMuted(tracks),
visible: isMobileBrowser() && videoInput.length > 1
visible: isToggleCameraEnabled(state)
};
}

Loading…
Cancel
Save