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

SharedVideoThumb.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.VideoLayout.handleVideoThumbClicked(this.url);
  48. };
  49. /**
  50. * Removes RemoteVideo from the page.
  51. */
  52. SharedVideoThumb.prototype.remove = function() {
  53. logger.log('Remove shared video thumb', this.id);
  54. // Make sure that the large video is updated if are removing its
  55. // corresponding small video.
  56. this.VideoLayout.updateAfterThumbRemoved(this.id);
  57. // Remove whole container
  58. if (this.container.parentNode) {
  59. this.container.parentNode.removeChild(this.container);
  60. }
  61. };
  62. /**
  63. * Sets the display name for the thumb.
  64. */
  65. SharedVideoThumb.prototype.setDisplayName = function(displayName) {
  66. if (!this.container) {
  67. logger.warn(`Unable to set displayName - ${this.videoSpanId
  68. } does not exist`);
  69. return;
  70. }
  71. this.updateDisplayName({
  72. displayName: displayName || '',
  73. elementID: `${this.videoSpanId}_name`,
  74. participantID: this.id
  75. });
  76. };