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.

SharedVideoThumb.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* global $, APP */
  2. import { shouldDisplayTileView } from '../../../react/features/video-layout';
  3. import SmallVideo from '../videolayout/SmallVideo';
  4. const logger = require('jitsi-meet-logger').getLogger(__filename);
  5. /**
  6. *
  7. */
  8. export default function SharedVideoThumb(participant, videoType, VideoLayout) {
  9. this.id = participant.id;
  10. this.url = participant.id;
  11. this.setVideoType(videoType);
  12. this.videoSpanId = 'sharedVideoContainer';
  13. this.container = this.createContainer(this.videoSpanId);
  14. this.$container = $(this.container);
  15. this.container.onclick = this.videoClick.bind(this);
  16. this.bindHoverHandler();
  17. SmallVideo.call(this, VideoLayout);
  18. this.isVideoMuted = true;
  19. this.setDisplayName(participant.name);
  20. }
  21. SharedVideoThumb.prototype = Object.create(SmallVideo.prototype);
  22. SharedVideoThumb.prototype.constructor = SharedVideoThumb;
  23. /**
  24. * hide display name
  25. */
  26. // eslint-disable-next-line no-empty-function
  27. SharedVideoThumb.prototype.setDeviceAvailabilityIcons = function() {};
  28. // eslint-disable-next-line no-empty-function
  29. SharedVideoThumb.prototype.avatarChanged = function() {};
  30. SharedVideoThumb.prototype.createContainer = function(spanId) {
  31. const container = document.createElement('span');
  32. container.id = spanId;
  33. container.className = 'videocontainer';
  34. // add the avatar
  35. const avatar = document.createElement('img');
  36. avatar.className = 'sharedVideoAvatar';
  37. avatar.src = `https://img.youtube.com/vi/${this.url}/0.jpg`;
  38. container.appendChild(avatar);
  39. const displayNameContainer = document.createElement('div');
  40. displayNameContainer.className = 'displayNameContainer';
  41. container.appendChild(displayNameContainer);
  42. const remoteVideosContainer
  43. = document.getElementById('filmstripRemoteVideosContainer');
  44. const localVideoContainer
  45. = document.getElementById('localVideoTileViewContainer');
  46. remoteVideosContainer.insertBefore(container, localVideoContainer);
  47. return container;
  48. };
  49. /**
  50. * The thumb click handler.
  51. */
  52. SharedVideoThumb.prototype.videoClick = function() {
  53. if (!shouldDisplayTileView(APP.store.getState())) {
  54. this._togglePin();
  55. }
  56. };
  57. /**
  58. * Removes RemoteVideo from the page.
  59. */
  60. SharedVideoThumb.prototype.remove = function() {
  61. logger.log('Remove shared video thumb', this.id);
  62. // Remove whole container
  63. if (this.container.parentNode) {
  64. this.container.parentNode.removeChild(this.container);
  65. }
  66. };
  67. /**
  68. * Sets the display name for the thumb.
  69. */
  70. SharedVideoThumb.prototype.setDisplayName = function(displayName) {
  71. if (!this.container) {
  72. logger.warn(`Unable to set displayName - ${this.videoSpanId
  73. } does not exist`);
  74. return;
  75. }
  76. this.updateDisplayName({
  77. displayName: displayName || '',
  78. elementID: `${this.videoSpanId}_name`,
  79. participantID: this.id
  80. });
  81. };