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

VideoQualityLabel.web.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // @flow
  2. import React from 'react';
  3. import { openDialog } from '../../base/dialog';
  4. import { translate } from '../../base/i18n';
  5. import { IconPerformance } from '../../base/icons';
  6. import { Label } from '../../base/label';
  7. import { COLORS } from '../../base/label/constants';
  8. import { connect } from '../../base/redux';
  9. import { Tooltip } from '../../base/tooltip';
  10. import { shouldDisplayTileView } from '../../video-layout';
  11. import AbstractVideoQualityLabel, {
  12. type Props as AbstractProps,
  13. _abstractMapStateToProps
  14. } from './AbstractVideoQualityLabel';
  15. import VideoQualityDialog from './VideoQualityDialog.web';
  16. declare var interfaceConfig: Object;
  17. type Props = AbstractProps & {
  18. /**
  19. * The redux dispatch function.
  20. */
  21. dispatch: Function,
  22. /**
  23. * The message to show within the label's tooltip.
  24. */
  25. _tooltipKey: string,
  26. /**
  27. * Flag controlling visibility of the component.
  28. */
  29. _visible: boolean,
  30. };
  31. /**
  32. * React {@code Component} responsible for displaying a label that indicates
  33. * the displayed video state of the current conference. {@code AudioOnlyLabel}
  34. * Will display when the conference is in audio only mode. {@code HDVideoLabel}
  35. * Will display if not in audio only mode and a high-definition large video is
  36. * being displayed.
  37. */
  38. export class VideoQualityLabel extends AbstractVideoQualityLabel<Props> {
  39. /**
  40. * Implements React's {@link Component#render()}.
  41. *
  42. * @inheritdoc
  43. * @returns {ReactElement}
  44. */
  45. render() {
  46. const {
  47. _audioOnly,
  48. _visible,
  49. dispatch,
  50. t
  51. } = this.props;
  52. if (!_visible) {
  53. return null;
  54. }
  55. let className, icon, labelContent, tooltipKey;
  56. if (_audioOnly) {
  57. className = 'audio-only';
  58. labelContent = t('videoStatus.audioOnly');
  59. tooltipKey = 'videoStatus.labelTooltipAudioOnly';
  60. } else {
  61. className = 'current-video-quality';
  62. icon = IconPerformance;
  63. tooltipKey = 'videoStatus.performanceSettings';
  64. }
  65. const onClick = () => dispatch(openDialog(VideoQualityDialog));
  66. return (
  67. <Tooltip
  68. content = { t(tooltipKey) }
  69. position = { 'bottom' }>
  70. <Label
  71. className = { className }
  72. color = { COLORS.white }
  73. icon = { icon }
  74. iconColor = '#fff'
  75. id = 'videoResolutionLabel'
  76. // eslint-disable-next-line react/jsx-no-bind
  77. onClick = { onClick }
  78. text = { labelContent } />
  79. </Tooltip>
  80. );
  81. }
  82. }
  83. /**
  84. * Maps (parts of) the Redux state to the associated {@code VideoQualityLabel}'s
  85. * props.
  86. *
  87. * @param {Object} state - The Redux state.
  88. * @private
  89. * @returns {{
  90. * _audioOnly: boolean,
  91. * _visible: boolean
  92. * }}
  93. */
  94. function _mapStateToProps(state) {
  95. return {
  96. ..._abstractMapStateToProps(state),
  97. _visible: !(shouldDisplayTileView(state) || interfaceConfig.VIDEO_QUALITY_LABEL_DISABLED)
  98. };
  99. }
  100. export default translate(connect(_mapStateToProps)(VideoQualityLabel));