您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SharedVideoThumb.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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(url, videoType, VideoLayout) {
  8. this.id = url;
  9. this.url = url;
  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. }
  19. SharedVideoThumb.prototype = Object.create(SmallVideo.prototype);
  20. SharedVideoThumb.prototype.constructor = SharedVideoThumb;
  21. /**
  22. * hide display name
  23. */
  24. // eslint-disable-next-line no-empty-function
  25. SharedVideoThumb.prototype.setDeviceAvailabilityIcons = function() {};
  26. // eslint-disable-next-line no-empty-function
  27. SharedVideoThumb.prototype.avatarChanged = function() {};
  28. SharedVideoThumb.prototype.createContainer = function(spanId) {
  29. const container = document.createElement('span');
  30. container.id = spanId;
  31. container.className = 'videocontainer';
  32. // add the avatar
  33. const avatar = document.createElement('img');
  34. avatar.className = 'sharedVideoAvatar';
  35. avatar.src = `https://img.youtube.com/vi/${this.url}/0.jpg`;
  36. container.appendChild(avatar);
  37. const displayNameContainer = document.createElement('div');
  38. displayNameContainer.className = 'displayNameContainer';
  39. container.appendChild(displayNameContainer);
  40. const remotes = document.getElementById('filmstripRemoteVideosContainer');
  41. return remotes.appendChild(container);
  42. };
  43. /**
  44. * The thumb click handler.
  45. */
  46. SharedVideoThumb.prototype.videoClick = function() {
  47. this._togglePin();
  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. };