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

middleware.web.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // @flow
  2. import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
  3. import { getLocalParticipant } from '../base/participants';
  4. import { MiddlewareRegistry } from '../base/redux';
  5. import { setDisableButton } from './actions.web';
  6. import { SHARED_VIDEO } from './constants';
  7. import './middleware.any';
  8. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  9. const state = getState();
  10. const localParticipantId = getLocalParticipant(state)?.id;
  11. switch (action.type) {
  12. case CONFERENCE_JOIN_IN_PROGRESS: {
  13. const { conference } = action;
  14. conference.addCommandListener(SHARED_VIDEO, ({ attributes }) => {
  15. const { from } = attributes;
  16. const status = attributes.state;
  17. if (status === 'playing') {
  18. if (localParticipantId !== from) {
  19. dispatch(setDisableButton(true));
  20. }
  21. } else if (status === 'stop') {
  22. dispatch(setDisableButton(false));
  23. }
  24. });
  25. break;
  26. }
  27. }
  28. return next(action);
  29. });