Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SharedVideoThumb.js 2.7KB

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