You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { setLastN } from '../../base/conference';
  2. import { setVideoMuted, VIDEO_MUTISM_AUTHORITY } from '../../base/media';
  3. import { _SET_APP_STATE_LISTENER, APP_STATE_CHANGED } from './actionTypes';
  4. /**
  5. * Sets the listener to be used with React Native's AppState API.
  6. *
  7. * @param {Function} listener - Function to be set as the change event listener.
  8. * @protected
  9. * @returns {{
  10. * type: _SET_APP_STATE_LISTENER,
  11. * listener: Function
  12. * }}
  13. */
  14. export function _setAppStateListener(listener: ?Function) {
  15. return {
  16. type: _SET_APP_STATE_LISTENER,
  17. listener
  18. };
  19. }
  20. /**
  21. * Signals that the app should mute video because it's now running in the
  22. * background, or unmute it because it came back from the background. If video
  23. * was already muted nothing will happen; otherwise, it will be muted. When
  24. * coming back from the background the previous state will be restored.
  25. *
  26. * @param {boolean} muted - True if video should be muted; false, otherwise.
  27. * @protected
  28. * @returns {Function}
  29. */
  30. export function _setBackgroundVideoMuted(muted: boolean) {
  31. return (dispatch, getState) => {
  32. // Disable remote video when we mute by setting lastN to 0. Skip it if
  33. // the conference is in audio-only mode, as it's already configured to
  34. // have no video. Leave it as undefined when unmuting, the default value
  35. // for last N will be chosen automatically.
  36. const { audioOnly } = getState()['features/base/conference'];
  37. audioOnly || dispatch(setLastN(muted ? 0 : undefined));
  38. dispatch(setVideoMuted(muted, VIDEO_MUTISM_AUTHORITY.BACKGROUND));
  39. };
  40. }
  41. /**
  42. * Signals that the App state has changed (in terms of execution state). The
  43. * application can be in 3 states: 'active', 'inactive' and 'background'.
  44. *
  45. * @param {string} appState - The new App state.
  46. * @public
  47. * @returns {{
  48. * type: APP_STATE_CHANGED,
  49. * appState: string
  50. * }}
  51. * @see {@link https://facebook.github.io/react-native/docs/appstate.html}
  52. */
  53. export function appStateChanged(appState: string) {
  54. return {
  55. type: APP_STATE_CHANGED,
  56. appState
  57. };
  58. }