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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* global $ */
  2. import SmallVideo from '../videolayout/SmallVideo';
  3. const logger = require('jitsi-meet-logger').getLogger(__filename);
  4. /**
  5. *
  6. */
  7. export default function SharedVideoThumb(participant, videoType, VideoLayout) {
  8. this.id = participant.id;
  9. this.url = participant.id;
  10. this.setVideoType(videoType);
  11. this.videoSpanId = 'sharedVideoContainer';
  12. this.container = this.createContainer(this.videoSpanId);
  13. this.$container = $(this.container);
  14. this.bindHoverHandler();
  15. SmallVideo.call(this, VideoLayout);
  16. this.isVideoMuted = true;
  17. this.setDisplayName(participant.name);
  18. this.container.onclick = this._onContainerClick;
  19. this.container.ondblclick = this._onContainerDoubleClick;
  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. * Removes RemoteVideo from the page.
  51. */
  52. SharedVideoThumb.prototype.remove = function() {
  53. logger.log('Remove shared video thumb', this.id);
  54. // Remove whole container
  55. if (this.container.parentNode) {
  56. this.container.parentNode.removeChild(this.container);
  57. }
  58. };
  59. /**
  60. * Sets the display name for the thumb.
  61. */
  62. SharedVideoThumb.prototype.setDisplayName = function(displayName) {
  63. if (!this.container) {
  64. logger.warn(`Unable to set displayName - ${this.videoSpanId
  65. } does not exist`);
  66. return;
  67. }
  68. this.updateDisplayName({
  69. displayName: displayName || '',
  70. elementID: `${this.videoSpanId}_name`,
  71. participantID: this.id
  72. });
  73. };