|
@@ -2,6 +2,7 @@
|
2
|
2
|
/* jshint -W101 */
|
3
|
3
|
import Avatar from "../avatar/Avatar";
|
4
|
4
|
import UIUtil from "../util/UIUtil";
|
|
5
|
+import UIEvents from "../../../service/UI/UIEvents";
|
5
|
6
|
|
6
|
7
|
const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
|
7
|
8
|
|
|
@@ -333,6 +334,16 @@ SmallVideo.prototype.removeModeratorIndicatorElement = function () {
|
333
|
334
|
$('#' + this.videoSpanId + ' .focusindicator').remove();
|
334
|
335
|
};
|
335
|
336
|
|
|
337
|
+/**
|
|
338
|
+ * This is an especially interesting function. A naive reader might think that
|
|
339
|
+ * it returns this SmallVideo's "video" element. But it is much more exciting.
|
|
340
|
+ * It first finds this video's parent element using jquery, then uses a utility
|
|
341
|
+ * from lib-jitsi-meet to extract the video element from it (with two more
|
|
342
|
+ * jquery calls), and finally uses jquery again to encapsulate the video element
|
|
343
|
+ * in an array. This last step allows (some might prefer "forces") users of
|
|
344
|
+ * this function to access the video element via the 0th element of the returned
|
|
345
|
+ * array (after checking its length of course!).
|
|
346
|
+ */
|
336
|
347
|
SmallVideo.prototype.selectVideoElement = function () {
|
337
|
348
|
return $(RTCUIHelper.findVideoElement($('#' + this.videoSpanId)[0]));
|
338
|
349
|
};
|
|
@@ -490,4 +501,37 @@ SmallVideo.prototype.getIndicatorSpan = function(id) {
|
490
|
501
|
return indicatorSpan;
|
491
|
502
|
};
|
492
|
503
|
|
|
504
|
+/**
|
|
505
|
+ * Adds a listener for onresize events for this video, which will monitor for
|
|
506
|
+ * resolution changes, will calculate the delay since the moment the listened
|
|
507
|
+ * is added, and will fire a RESOLUTION_CHANGED event.
|
|
508
|
+ */
|
|
509
|
+SmallVideo.prototype.waitForResolutionChange = function() {
|
|
510
|
+ let self = this;
|
|
511
|
+ let beforeChange = window.performance.now();
|
|
512
|
+ let videos = this.selectVideoElement();
|
|
513
|
+ if (!videos || !videos.length || videos.length <= 0)
|
|
514
|
+ return;
|
|
515
|
+ let video = videos[0];
|
|
516
|
+ let oldWidth = video.videoWidth;
|
|
517
|
+ let oldHeight = video.videoHeight;
|
|
518
|
+ video.onresize = (event) => {
|
|
519
|
+ if (video.videoWidth != oldWidth || video.videoHeight != oldHeight) {
|
|
520
|
+ // Only run once.
|
|
521
|
+ video.onresize = null;
|
|
522
|
+
|
|
523
|
+ let delay = window.performance.now() - beforeChange;
|
|
524
|
+ let emitter = self.VideoLayout.getEventEmitter();
|
|
525
|
+ if (emitter) {
|
|
526
|
+ emitter.emit(
|
|
527
|
+ UIEvents.RESOLUTION_CHANGED,
|
|
528
|
+ self.getId(),
|
|
529
|
+ oldWidth + "x" + oldHeight,
|
|
530
|
+ video.videoWidth + "x" + video.videoHeight,
|
|
531
|
+ delay);
|
|
532
|
+ }
|
|
533
|
+ }
|
|
534
|
+ };
|
|
535
|
+};
|
|
536
|
+
|
493
|
537
|
export default SmallVideo;
|