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.

LargeVideoBackground.web.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { Video } from '../../base/media';
  4. /**
  5. * Constants to describe the dimensions of the video. Landscape videos
  6. * are wider than they are taller and portrait videos are taller than they
  7. * are wider. The dimensions will determine how {@code LargeVideoBackground}
  8. * will strech to fill its container.
  9. *
  10. * @type {Object}
  11. */
  12. export const ORIENTATION = {
  13. LANDSCAPE: 'landscape',
  14. PORTRAIT: 'portrait'
  15. };
  16. /**
  17. * A mapping of orientations to a class that should fit the
  18. * {@code LargeVideoBackground} into its container.
  19. *
  20. * @private
  21. * @type {Object}
  22. */
  23. const ORIENTATION_TO_CLASS = {
  24. [ORIENTATION.LANDSCAPE]: 'fit-full-width',
  25. [ORIENTATION.PORTRAIT]: 'fit-full-height'
  26. };
  27. /**
  28. * Implements a React Component which shows a video element intended to be used
  29. * as a background to fill the empty space of container with another video.
  30. *
  31. * @extends Component
  32. */
  33. export class LargeVideoBackground extends Component {
  34. /**
  35. * {@code LargeVideoBackground} component's property types.
  36. *
  37. * @static
  38. */
  39. static propTypes = {
  40. /**
  41. * Additional CSS class names to add to the root of the component.
  42. */
  43. className: PropTypes.string,
  44. /**
  45. * Whether or not the background should have its visibility hidden.
  46. */
  47. hidden: PropTypes.bool,
  48. /**
  49. * Whether or not the video should display flipped horizontally, so
  50. * left becomes right and right becomes left.
  51. */
  52. mirror: PropTypes.bool,
  53. /**
  54. * Whether the component should ensure full width of the video is
  55. * displayed (landscape) or full height (portrait).
  56. */
  57. orientationFit: PropTypes.oneOf([
  58. ORIENTATION.LANDSCAPE,
  59. ORIENTATION.PORTRAIT
  60. ]),
  61. /**
  62. * Whether or not to display a filter on the video to visually indicate
  63. * a problem with the video being displayed.
  64. */
  65. showLocalProblemFilter: PropTypes.bool,
  66. /**
  67. * Whether or not to display a filter on the video to visually indicate
  68. * a problem with the video being displayed.
  69. */
  70. showRemoteProblemFilter: PropTypes.bool,
  71. /**
  72. * The video stream to display.
  73. */
  74. videoTrack: PropTypes.object
  75. };
  76. /**
  77. * Implements React's {@link Component#render()}.
  78. *
  79. * @inheritdoc
  80. * @returns {ReactElement}
  81. */
  82. render() {
  83. const {
  84. hidden,
  85. mirror,
  86. orientationFit,
  87. showLocalProblemFilter,
  88. showRemoteProblemFilter,
  89. videoTrack
  90. } = this.props;
  91. const orientationClass = orientationFit
  92. ? ORIENTATION_TO_CLASS[orientationFit] : '';
  93. const classNames = `large-video-background ${mirror ? 'flip-x' : ''} ${
  94. hidden ? 'invisible' : ''} ${orientationClass} ${
  95. showLocalProblemFilter ? 'videoProblemFilter' : ''} ${
  96. showRemoteProblemFilter ? 'remoteVideoProblemFilter' : ''}`;
  97. const videoTrackModel = {
  98. jitsiTrack: hidden ? null : videoTrack
  99. };
  100. return (
  101. <div className = { classNames }>
  102. <Video
  103. autoPlay = { true }
  104. id = 'largeVideoBackground'
  105. videoTrack = { videoTrackModel } />
  106. </div>
  107. );
  108. }
  109. }