Przeglądaj źródła

ref(shared-video): move SharedVideoThumb to own file

j8
Leonard Kim 7 lat temu
rodzic
commit
7cea557416

+ 4
- 86
modules/UI/shared_video/SharedVideo.js Wyświetl plik

@@ -7,7 +7,6 @@ import UIEvents from '../../../service/UI/UIEvents';
7 7
 
8 8
 import VideoLayout from "../videolayout/VideoLayout";
9 9
 import LargeContainer from '../videolayout/LargeContainer';
10
-import SmallVideo from '../videolayout/SmallVideo';
11 10
 import Filmstrip from '../videolayout/Filmstrip';
12 11
 
13 12
 import {
@@ -16,6 +15,8 @@ import {
16 15
 } from '../../../react/features/base/participants';
17 16
 import { dockToolbox, showToolbox } from '../../../react/features/toolbox';
18 17
 
18
+import SharedVideoThumb from './SharedVideoThumb';
19
+
19 20
 export const SHARED_VIDEO_CONTAINER_TYPE = "sharedvideo";
20 21
 
21 22
 /**
@@ -255,7 +256,8 @@ export default class SharedVideoManager {
255 256
             // in onPlayerStateChange
256 257
             player.playVideo();
257 258
 
258
-            let thumb = new SharedVideoThumb(self.url);
259
+            let thumb = new SharedVideoThumb(
260
+                self.url, SHARED_VIDEO_CONTAINER_TYPE, VideoLayout);
259 261
             thumb.setDisplayName(player.getVideoData().title);
260 262
             VideoLayout.addRemoteVideoContainer(self.url, thumb);
261 263
 
@@ -639,90 +641,6 @@ class SharedVideoContainer extends LargeContainer {
639 641
     }
640 642
 }
641 643
 
642
-function SharedVideoThumb (url)
643
-{
644
-    this.id = url;
645
-
646
-    this.url = url;
647
-    this.setVideoType(SHARED_VIDEO_CONTAINER_TYPE);
648
-    this.videoSpanId = "sharedVideoContainer";
649
-    this.container = this.createContainer(this.videoSpanId);
650
-    this.$container = $(this.container);
651
-    this.container.onclick = this.videoClick.bind(this);
652
-    this.bindHoverHandler();
653
-    SmallVideo.call(this, VideoLayout);
654
-    this.isVideoMuted = true;
655
-}
656
-SharedVideoThumb.prototype = Object.create(SmallVideo.prototype);
657
-SharedVideoThumb.prototype.constructor = SharedVideoThumb;
658
-
659
-/**
660
- * hide display name
661
- */
662
-
663
-SharedVideoThumb.prototype.setDeviceAvailabilityIcons = function () {};
664
-
665
-SharedVideoThumb.prototype.avatarChanged = function () {};
666
-
667
-SharedVideoThumb.prototype.createContainer = function (spanId) {
668
-    var container = document.createElement('span');
669
-    container.id = spanId;
670
-    container.className = 'videocontainer';
671
-
672
-    // add the avatar
673
-    var avatar = document.createElement('img');
674
-    avatar.className = 'sharedVideoAvatar';
675
-    avatar.src = "https://img.youtube.com/vi/" + this.url + "/0.jpg";
676
-    container.appendChild(avatar);
677
-
678
-    const displayNameContainer = document.createElement('div');
679
-    displayNameContainer.className = 'displayNameContainer';
680
-    container.appendChild(displayNameContainer);
681
-
682
-    var remotes = document.getElementById('filmstripRemoteVideosContainer');
683
-    return remotes.appendChild(container);
684
-};
685
-
686
-/**
687
- * The thumb click handler.
688
- */
689
-SharedVideoThumb.prototype.videoClick = function () {
690
-    VideoLayout.handleVideoThumbClicked(this.url);
691
-};
692
-
693
-/**
694
- * Removes RemoteVideo from the page.
695
- */
696
-SharedVideoThumb.prototype.remove = function () {
697
-    logger.log("Remove shared video thumb", this.id);
698
-
699
-    // Make sure that the large video is updated if are removing its
700
-    // corresponding small video.
701
-    this.VideoLayout.updateAfterThumbRemoved(this.id);
702
-
703
-    // Remove whole container
704
-    if (this.container.parentNode) {
705
-        this.container.parentNode.removeChild(this.container);
706
-    }
707
-};
708
-
709
-/**
710
- * Sets the display name for the thumb.
711
- */
712
-SharedVideoThumb.prototype.setDisplayName = function(displayName) {
713
-    if (!this.container) {
714
-        logger.warn( "Unable to set displayName - " + this.videoSpanId +
715
-            " does not exist");
716
-        return;
717
-    }
718
-
719
-    this.updateDisplayName({
720
-        displayName: displayName || '',
721
-        elementID: `${this.videoSpanId}_name`,
722
-        participantID: this.id
723
-    });
724
-};
725
-
726 644
 /**
727 645
  * Checks if given string is youtube url.
728 646
  * @param {string} url string to check.

+ 88
- 0
modules/UI/shared_video/SharedVideoThumb.js Wyświetl plik

@@ -0,0 +1,88 @@
1
+/* global $ */
2
+import SmallVideo from '../videolayout/SmallVideo';
3
+
4
+const logger = require("jitsi-meet-logger").getLogger(__filename);
5
+
6
+export default function SharedVideoThumb (url, videoType, VideoLayout)
7
+{
8
+    this.id = url;
9
+
10
+    this.url = url;
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
+}
20
+SharedVideoThumb.prototype = Object.create(SmallVideo.prototype);
21
+SharedVideoThumb.prototype.constructor = SharedVideoThumb;
22
+
23
+/**
24
+ * hide display name
25
+ */
26
+
27
+SharedVideoThumb.prototype.setDeviceAvailabilityIcons = function () {};
28
+
29
+SharedVideoThumb.prototype.avatarChanged = function () {};
30
+
31
+SharedVideoThumb.prototype.createContainer = function (spanId) {
32
+    var container = document.createElement('span');
33
+    container.id = spanId;
34
+    container.className = 'videocontainer';
35
+
36
+    // add the avatar
37
+    var avatar = document.createElement('img');
38
+    avatar.className = 'sharedVideoAvatar';
39
+    avatar.src = "https://img.youtube.com/vi/" + this.url + "/0.jpg";
40
+    container.appendChild(avatar);
41
+
42
+    const displayNameContainer = document.createElement('div');
43
+    displayNameContainer.className = 'displayNameContainer';
44
+    container.appendChild(displayNameContainer);
45
+
46
+    var remotes = document.getElementById('filmstripRemoteVideosContainer');
47
+    return remotes.appendChild(container);
48
+};
49
+
50
+/**
51
+ * The thumb click handler.
52
+ */
53
+SharedVideoThumb.prototype.videoClick = function () {
54
+    this.VideoLayout.handleVideoThumbClicked(this.url);
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
+
63
+    // Make sure that the large video is updated if are removing its
64
+    // corresponding small video.
65
+    this.VideoLayout.updateAfterThumbRemoved(this.id);
66
+
67
+    // Remove whole container
68
+    if (this.container.parentNode) {
69
+        this.container.parentNode.removeChild(this.container);
70
+    }
71
+};
72
+
73
+/**
74
+ * Sets the display name for the thumb.
75
+ */
76
+SharedVideoThumb.prototype.setDisplayName = function(displayName) {
77
+    if (!this.container) {
78
+        logger.warn( "Unable to set displayName - " + this.videoSpanId +
79
+            " does not exist");
80
+        return;
81
+    }
82
+
83
+    this.updateDisplayName({
84
+        displayName: displayName || '',
85
+        elementID: `${this.videoSpanId}_name`,
86
+        participantID: this.id
87
+    });
88
+};

Ładowanie…
Anuluj
Zapisz