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.

middleware.web.ts 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
  2. import { getLocalParticipant } from '../base/participants/functions';
  3. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  4. import { setDisableButton } from './actions.web';
  5. import { PLAYBACK_STATUSES, SHARED_VIDEO } from './constants';
  6. import { isSharedVideoEnabled } from './functions';
  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. if (!isSharedVideoEnabled(state)) {
  14. break;
  15. }
  16. const { conference } = action;
  17. conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes:
  18. { from: string; state: string; }; }) => {
  19. const { from } = attributes;
  20. const status = attributes.state;
  21. if (status === PLAYBACK_STATUSES.PLAYING) {
  22. if (localParticipantId !== from) {
  23. dispatch(setDisableButton(true));
  24. }
  25. } else if (status === 'stop') {
  26. dispatch(setDisableButton(false));
  27. }
  28. });
  29. break;
  30. }
  31. }
  32. return next(action);
  33. });