Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RecordingLabel.web.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../base/i18n';
  5. import { JitsiRecordingStatus } from '../../base/lib-jitsi-meet';
  6. import { RECORDING_TYPES } from '../constants';
  7. /**
  8. * Implements a React {@link Component} which displays the current state of
  9. * conference recording. Currently it uses CSS to display itself automatically
  10. * when there is a recording state update.
  11. *
  12. * @extends {Component}
  13. */
  14. class RecordingLabel extends Component {
  15. /**
  16. * {@code RecordingLabel} component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. /**
  22. * Whether or not the filmstrip is currently visible or toggled to
  23. * hidden. Depending on the filmstrip state, different CSS classes will
  24. * be set to allow for adjusting of {@code RecordingLabel} positioning.
  25. */
  26. _filmstripVisible: PropTypes.bool,
  27. /**
  28. * Whether or not the conference is currently being recorded.
  29. */
  30. _isRecording: PropTypes.bool,
  31. /**
  32. * An object to describe the {@code RecordingLabel} content. If no
  33. * translation key to display is specified, the label will apply CSS to
  34. * itself so it can be made invisible.
  35. * {{
  36. * centered: boolean,
  37. * key: string,
  38. * showSpinner: boolean
  39. * }}
  40. */
  41. _labelDisplayConfiguration: PropTypes.object,
  42. /**
  43. * Whether the recording feature is live streaming (jibri) or is file
  44. * recording (jirecon).
  45. */
  46. _recordingType: PropTypes.string,
  47. /**
  48. * Invoked to obtain translated string.
  49. */
  50. t: PropTypes.func
  51. };
  52. /**
  53. * Initializes a new {@code RecordingLabel} instance.
  54. *
  55. * @param {Object} props - The read-only properties with which the new
  56. * instance is to be initialized.
  57. */
  58. constructor(props) {
  59. super(props);
  60. this.state = {
  61. /**
  62. * Whether or not the filmstrip was not visible but has transitioned
  63. * in the latest component update to visible. This boolean is used
  64. * to set a class for position animations.
  65. *
  66. * @type {boolean}
  67. */
  68. filmstripBecomingVisible: false
  69. };
  70. }
  71. /**
  72. * Updates the state for whether or not the filmstrip is being toggled to
  73. * display after having being hidden.
  74. *
  75. * @inheritdoc
  76. * @param {Object} nextProps - The read-only props which this Component will
  77. * receive.
  78. * @returns {void}
  79. */
  80. componentWillReceiveProps(nextProps) {
  81. this.setState({
  82. filmstripBecomingVisible: nextProps._filmstripVisible
  83. && !this.props._filmstripVisible
  84. });
  85. }
  86. /**
  87. * Implements React's {@link Component#render()}.
  88. *
  89. * @inheritdoc
  90. * @returns {ReactElement}
  91. */
  92. render() {
  93. const {
  94. _isRecording,
  95. _labelDisplayConfiguration,
  96. _recordingType
  97. } = this.props;
  98. const { centered, key, showSpinner } = _labelDisplayConfiguration || {};
  99. const isVisible = Boolean(key);
  100. const rootClassName = [
  101. 'video-state-indicator centeredVideoLabel',
  102. _isRecording ? 'is-recording' : '',
  103. isVisible ? 'show-inline' : '',
  104. centered ? '' : 'moveToCorner',
  105. this.state.filmstripBecomingVisible ? 'opening' : '',
  106. this.props._filmstripVisible
  107. ? 'with-filmstrip' : 'without-filmstrip'
  108. ].join(' ');
  109. return (
  110. <div
  111. className = { rootClassName }
  112. id = 'recordingLabel'>
  113. { _isRecording
  114. ? <div className = 'recording-icon'>
  115. <div className = 'recording-icon-background' />
  116. <i
  117. className = {
  118. _recordingType === RECORDING_TYPES.JIBRI
  119. ? 'icon-live'
  120. : 'icon-rec' } />
  121. </div>
  122. : <div id = 'recordingLabelText'>
  123. { this.props.t(key) }
  124. </div> }
  125. { !_isRecording
  126. && showSpinner
  127. && <img
  128. className = 'recordingSpinner'
  129. id = 'recordingSpinner'
  130. src = 'images/spin.svg' /> }
  131. </div>
  132. );
  133. }
  134. }
  135. /**
  136. * Maps (parts of) the Redux state to the associated {@code RecordingLabel}
  137. * component's props.
  138. *
  139. * @param {Object} state - The Redux state.
  140. * @private
  141. * @returns {{
  142. * _filmstripVisible: boolean,
  143. * _isRecording: boolean,
  144. * _labelDisplayConfiguration: Object,
  145. * _recordingType: string
  146. * }}
  147. */
  148. function _mapStateToProps(state) {
  149. const { visible } = state['features/filmstrip'];
  150. const {
  151. labelDisplayConfiguration,
  152. recordingState,
  153. recordingType
  154. } = state['features/recording'];
  155. return {
  156. _filmstripVisible: visible,
  157. _isRecording: recordingState === JitsiRecordingStatus.ON,
  158. _labelDisplayConfiguration: labelDisplayConfiguration,
  159. _recordingType: recordingType
  160. };
  161. }
  162. export default translate(connect(_mapStateToProps)(RecordingLabel));