Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

VideoQualityLabel.web.js 3.0KB

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