您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { setLastN } from '../../base/conference';
  2. import { setVideoMuted, VIDEO_MUTISM_AUTHORITY } from '../../base/media';
  3. import {
  4. _SET_APP_STATE_LISTENER,
  5. APP_STATE_CHANGED
  6. } from './actionTypes';
  7. /**
  8. * Sets the listener to be used with React Native's AppState API.
  9. *
  10. * @param {Function} listener - Function to be set as the change event listener.
  11. * @protected
  12. * @returns {{
  13. * type: _SET_APP_STATE_LISTENER,
  14. * listener: Function
  15. * }}
  16. */
  17. export function _setAppStateListener(listener: ?Function) {
  18. return {
  19. type: _SET_APP_STATE_LISTENER,
  20. listener
  21. };
  22. }
  23. /**
  24. * Signals that the app should mute video because it's now running in the
  25. * background, or unmute it because it came back from the background. If video
  26. * was already muted nothing will happen; otherwise, it will be muted. When
  27. * coming back from the background the previous state will be restored.
  28. *
  29. * @param {boolean} muted - True if video should be muted; false, otherwise.
  30. * @protected
  31. * @returns {Function}
  32. */
  33. export function _setBackgroundVideoMuted(muted: boolean) {
  34. return (dispatch, getState) => {
  35. // Disable remote video when we mute by setting lastN to 0. Skip it if
  36. // the conference is in audio-only mode, as it's already configured to
  37. // have no video. Leave it as undefined when unmuting, the default value
  38. // for last N will be chosen automatically.
  39. const { audioOnly } = getState()['features/base/conference'];
  40. !audioOnly && dispatch(setLastN(muted ? 0 : undefined));
  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. }