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.

RemoteControlButton.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { translate } from '../../base/i18n';
  4. import RemoteVideoMenuButton from './RemoteVideoMenuButton';
  5. // TODO: Move these enums into the store after further reactification of the
  6. // non-react RemoteVideo component.
  7. export const REMOTE_CONTROL_MENU_STATES = {
  8. NOT_SUPPORTED: 0,
  9. NOT_STARTED: 1,
  10. REQUESTING: 2,
  11. STARTED: 3
  12. };
  13. /**
  14. * Implements a React {@link Component} which displays a button showing the
  15. * current state of remote control for a participant and can start or stop a
  16. * remote control session.
  17. *
  18. * @extends Component
  19. */
  20. class RemoteControlButton extends Component {
  21. /**
  22. * {@code RemoteControlButton} component's property types.
  23. *
  24. * @static
  25. */
  26. static propTypes = {
  27. /**
  28. * The callback to invoke when the component is clicked.
  29. */
  30. onClick: PropTypes.func,
  31. /**
  32. * The ID of the participant linked to the onClick callback.
  33. */
  34. participantID: PropTypes.string,
  35. /**
  36. * The current status of remote control. Should be a number listed in
  37. * the enum REMOTE_CONTROL_MENU_STATES.
  38. */
  39. remoteControlState: PropTypes.number,
  40. /**
  41. * Invoked to obtain translated strings.
  42. */
  43. t: PropTypes.func
  44. };
  45. /**
  46. * Implements React's {@link Component#render()}.
  47. *
  48. * @inheritdoc
  49. * @returns {null|ReactElement}
  50. */
  51. render() {
  52. const {
  53. onClick,
  54. participantID,
  55. remoteControlState,
  56. t
  57. } = this.props;
  58. let className, icon;
  59. switch (remoteControlState) {
  60. case REMOTE_CONTROL_MENU_STATES.NOT_STARTED:
  61. className = 'requestRemoteControlLink';
  62. icon = 'fa fa-play';
  63. break;
  64. case REMOTE_CONTROL_MENU_STATES.REQUESTING:
  65. className = 'requestRemoteControlLink disabled';
  66. icon = 'remote-control-spinner fa fa-spinner fa-spin';
  67. break;
  68. case REMOTE_CONTROL_MENU_STATES.STARTED:
  69. className = 'requestRemoteControlLink';
  70. icon = 'fa fa-stop';
  71. break;
  72. case REMOTE_CONTROL_MENU_STATES.NOT_SUPPORTED:
  73. // Intentionally fall through.
  74. default:
  75. return null;
  76. }
  77. return (
  78. <RemoteVideoMenuButton
  79. buttonText = { t('videothumbnail.remoteControl') }
  80. displayClass = { className }
  81. iconClass = { icon }
  82. id = { `remoteControl_${participantID}` }
  83. onClick = { onClick } />
  84. );
  85. }
  86. }
  87. export default translate(RemoteControlButton);