Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.js 2.2KB

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