Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

MuteVideoButton.tsx 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import React, { useCallback, useMemo } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch, useSelector } from 'react-redux';
  4. import { createRemoteVideoMenuButtonEvent } from '../../../analytics/AnalyticsEvents';
  5. import { sendAnalytics } from '../../../analytics/functions';
  6. import { IReduxState } from '../../../app/types';
  7. import { openDialog } from '../../../base/dialog/actions';
  8. import { IconVideoOff } from '../../../base/icons/svg';
  9. import { MEDIA_TYPE } from '../../../base/media/constants';
  10. import { isRemoteTrackMuted } from '../../../base/tracks/functions.any';
  11. import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
  12. import { NOTIFY_CLICK_MODE } from '../../../toolbox/constants';
  13. import { IButtonProps } from '../../types';
  14. import MuteRemoteParticipantsVideoDialog from './MuteRemoteParticipantsVideoDialog';
  15. /**
  16. * Implements a React {@link Component} which displays a button for disabling
  17. * the camera of a participant in the conference.
  18. *
  19. * @returns {JSX.Element|null}
  20. */
  21. const MuteVideoButton = ({
  22. notifyClick,
  23. notifyMode,
  24. participantID
  25. }: IButtonProps): JSX.Element | null => {
  26. const { t } = useTranslation();
  27. const dispatch = useDispatch();
  28. const tracks = useSelector((state: IReduxState) => state['features/base/tracks']);
  29. const videoTrackMuted = useMemo(
  30. () => isRemoteTrackMuted(tracks, MEDIA_TYPE.VIDEO, participantID),
  31. [ isRemoteTrackMuted, participantID, tracks ]
  32. );
  33. const handleClick = useCallback(() => {
  34. notifyClick?.();
  35. if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
  36. return;
  37. }
  38. sendAnalytics(createRemoteVideoMenuButtonEvent(
  39. 'video.mute.button',
  40. {
  41. 'participant_id': participantID
  42. }));
  43. dispatch(openDialog(MuteRemoteParticipantsVideoDialog, { participantID }));
  44. }, [ dispatch, notifyClick, notifyClick, participantID, sendAnalytics ]);
  45. if (videoTrackMuted) {
  46. return null;
  47. }
  48. return (
  49. <ContextMenuItem
  50. accessibilityLabel = { t('participantsPane.actions.stopVideo') }
  51. className = 'mutevideolink'
  52. icon = { IconVideoOff }
  53. onClick = { handleClick }
  54. text = { t('participantsPane.actions.stopVideo') } />
  55. );
  56. };
  57. export default MuteVideoButton;