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

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