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

middleware.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { JitsiTrackEvents } from '../base/lib-jitsi-meet';
  2. import { MiddlewareRegistry } from '../base/redux';
  3. import { getLocalVideoTrack } from '../base/tracks';
  4. import { toggleBackgroundEffect } from './actions';
  5. /**
  6. * Middleware which intercepts the desktop video type on
  7. * virtual background. If the user stops the screen share
  8. * then the default virtual background is set to 'none' option
  9. *
  10. * @param {Store} store - The redux store.
  11. * @returns {Function}
  12. */
  13. MiddlewareRegistry.register(store => next => action => {
  14. const { dispatch, getState } = store;
  15. const virtualSource = getState()['features/virtual-background'].virtualSource;
  16. const currentLocalTrack = getLocalVideoTrack(getState()['features/base/tracks']);
  17. if (virtualSource?.videoType === 'desktop') {
  18. const noneOptions = {
  19. enabled: false,
  20. backgroundType: 'none',
  21. selectedThumbnail: 'none',
  22. backgroundEffectEnabled: false
  23. };
  24. virtualSource
  25. && virtualSource.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, () => {
  26. dispatch(toggleBackgroundEffect(noneOptions, currentLocalTrack.jitsiTrack));
  27. });
  28. }
  29. return next(action);
  30. });