2017-02-03 18:50:06 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import {
|
2017-01-11 18:14:00 +00:00
|
|
|
SET_AUDIO_MUTED,
|
|
|
|
SET_CAMERA_FACING_MODE,
|
2017-04-03 08:57:01 +00:00
|
|
|
SET_VIDEO_MUTED,
|
|
|
|
TOGGLE_CAMERA_FACING_MODE
|
2016-10-05 14:36:59 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
import { CAMERA_FACING_MODE } from './constants';
|
|
|
|
|
|
|
|
/**
|
2017-01-17 14:32:20 +00:00
|
|
|
* Action to set the muted state of the local audio.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-01-17 14:32:20 +00:00
|
|
|
* @param {boolean} muted - True if the local audio is to be muted or false if
|
|
|
|
* the local audio is to be unmuted.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-01-11 18:14:00 +00:00
|
|
|
* type: SET_AUDIO_MUTED,
|
2016-10-05 14:36:59 +00:00
|
|
|
* muted: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
2017-02-03 18:50:06 +00:00
|
|
|
export function setAudioMuted(muted: boolean) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2017-01-11 18:14:00 +00:00
|
|
|
type: SET_AUDIO_MUTED,
|
2016-10-05 14:36:59 +00:00
|
|
|
muted
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-17 14:32:20 +00:00
|
|
|
* Action to set the facing mode of the local camera.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-01-17 14:32:20 +00:00
|
|
|
* @param {CAMERA_FACING_MODE} cameraFacingMode - The camera facing mode to set.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-01-11 18:14:00 +00:00
|
|
|
* type: SET_CAMERA_FACING_MODE,
|
2016-10-05 14:36:59 +00:00
|
|
|
* cameraFacingMode: CAMERA_FACING_MODE
|
|
|
|
* }}
|
|
|
|
*/
|
2017-02-03 18:50:06 +00:00
|
|
|
export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2017-01-11 18:14:00 +00:00
|
|
|
type: SET_CAMERA_FACING_MODE,
|
2016-10-05 14:36:59 +00:00
|
|
|
cameraFacingMode
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-17 14:32:20 +00:00
|
|
|
/**
|
|
|
|
* Action to set the muted state of the local video.
|
|
|
|
*
|
|
|
|
* @param {boolean} muted - True if the local video is to be muted or false if
|
|
|
|
* the local video is to be unmuted.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_VIDEO_MUTED,
|
|
|
|
* muted: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
2017-02-03 18:50:06 +00:00
|
|
|
export function setVideoMuted(muted: boolean) {
|
2017-01-17 14:32:20 +00:00
|
|
|
return {
|
|
|
|
type: SET_VIDEO_MUTED,
|
|
|
|
muted
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Toggles the mute state of the local audio track(s).
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function toggleAudioMuted() {
|
2017-02-03 18:50:06 +00:00
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
2016-10-05 14:36:59 +00:00
|
|
|
const muted = getState()['features/base/media'].audio.muted;
|
|
|
|
|
2017-01-11 18:14:00 +00:00
|
|
|
return dispatch(setAudioMuted(!muted));
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-03 08:57:01 +00:00
|
|
|
* Toggles the camera facing mode. Most commonly, for example, mobile devices
|
|
|
|
* such as phones have a front/user-facing and a back/environment-facing
|
|
|
|
* cameras. In contrast to setCameraFacingMode, allows the toggling to be
|
|
|
|
* optimally and/or natively implemented without the overhead of separate reads
|
|
|
|
* and writes of the current/effective camera facing mode.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-04-03 08:57:01 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: TOGGLE_CAMERA_FACING_MODE
|
|
|
|
* }}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
export function toggleCameraFacingMode() {
|
2017-04-03 08:57:01 +00:00
|
|
|
return {
|
|
|
|
type: TOGGLE_CAMERA_FACING_MODE
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the mute state of the local video track(s).
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function toggleVideoMuted() {
|
2017-02-03 18:50:06 +00:00
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
2016-10-05 14:36:59 +00:00
|
|
|
const muted = getState()['features/base/media'].video.muted;
|
|
|
|
|
2017-01-11 18:14:00 +00:00
|
|
|
return dispatch(setVideoMuted(!muted));
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|