Bladeren bron

fix(thumbnail): videos on safari.

j8
Hristo Terezov 5 jaren geleden
bovenliggende
commit
f972ebfe9e
3 gewijzigde bestanden met toevoegingen van 19 en 29 verwijderingen
  1. 5
    2
      modules/UI/util/UIUtil.js
  2. 13
    26
      modules/UI/videolayout/RemoteVideo.js
  3. 1
    1
      modules/UI/videolayout/SmallVideo.js

+ 5
- 2
modules/UI/util/UIUtil.js Bestand weergeven

@@ -27,12 +27,15 @@ const UIUtil = {
27 27
      */
28 28
     prependChild(container, newChild) {
29 29
         const firstChild = container.childNodes[0];
30
+        let result;
30 31
 
31 32
         if (firstChild) {
32
-            container.insertBefore(newChild, firstChild);
33
+            result = container.insertBefore(newChild, firstChild);
33 34
         } else {
34
-            container.appendChild(newChild);
35
+            result = container.appendChild(newChild);
35 36
         }
37
+
38
+        return result;
36 39
     },
37 40
 
38 41
     /**

+ 13
- 26
modules/UI/videolayout/RemoteVideo.js Bestand weergeven

@@ -90,13 +90,13 @@ export default class RemoteVideo extends SmallVideo {
90 90
         this._isRemoteControlSessionActive = false;
91 91
 
92 92
         /**
93
-         * The flag is set to <tt>true</tt> after the 'onplay' event has been
93
+         * The flag is set to <tt>true</tt> after the 'canplay' event has been
94 94
          * triggered on the current video element. It goes back to <tt>false</tt>
95 95
          * when the stream is removed. It is used to determine whether the video
96 96
          * playback has ever started.
97 97
          * @type {boolean}
98 98
          */
99
-        this.wasVideoPlayed = false;
99
+        this._canPlayEventReceived = false;
100 100
 
101 101
         /**
102 102
          * The flag is set to <tt>true</tt> if remote participant's video gets muted
@@ -366,7 +366,7 @@ export default class RemoteVideo extends SmallVideo {
366 366
 
367 367
         select.remove();
368 368
         if (isVideo) {
369
-            this.wasVideoPlayed = false;
369
+            this._canPlayEventReceived = false;
370 370
         }
371 371
 
372 372
         logger.info(`${isVideo ? 'Video' : 'Audio'} removed ${this.id}`, select);
@@ -390,13 +390,10 @@ export default class RemoteVideo extends SmallVideo {
390 390
     }
391 391
 
392 392
     /**
393
-     * The remote video is considered "playable" once the stream has started
394
-     * according to the {@link #hasVideoStarted} result.
395
-     * It will be allowed to display video also in
396
-     * {@link JitsiParticipantConnectionStatus.INTERRUPTED} if the video was ever
397
-     *  played and was not muted while not in ACTIVE state. This basically means
398
-     * that there is stalled video image cached that could be displayed. It's used
399
-     * to show "grey video image" in user's thumbnail when there are connectivity
393
+     * The remote video is considered "playable" once the can play event has been received. It will be allowed to
394
+     * display video also in {@link JitsiParticipantConnectionStatus.INTERRUPTED} if the video has received the canplay
395
+     * event and was not muted while not in ACTIVE state. This basically means that there is stalled video image cached
396
+     * that could be displayed. It's used to show "grey video image" in user's thumbnail when there are connectivity
400 397
      * issues.
401 398
      *
402 399
      * @inheritdoc
@@ -406,7 +403,7 @@ export default class RemoteVideo extends SmallVideo {
406 403
         const connectionState = APP.conference.getParticipantConnectionStatus(this.id);
407 404
 
408 405
         return super.isVideoPlayable()
409
-            && this.hasVideoStarted()
406
+            && this._canPlayEventReceived
410 407
             && (connectionState === JitsiParticipantConnectionStatus.ACTIVE
411 408
                 || (connectionState === JitsiParticipantConnectionStatus.INTERRUPTED && !this.mutedWhileDisconnected));
412 409
     }
@@ -459,26 +456,16 @@ export default class RemoteVideo extends SmallVideo {
459 456
             return;
460 457
         }
461 458
 
462
-        streamElement.onplaying = () => {
463
-            this.wasVideoPlayed = true;
459
+        streamElement.oncanplay = () => {
460
+            this._canPlayEventReceived = true;
464 461
             this.VideoLayout.remoteVideoActive(streamElement, this.id);
465
-            streamElement.onplaying = null;
462
+            streamElement.oncanplay = undefined;
466 463
 
467 464
             // Refresh to show the video
468 465
             this.updateView();
469 466
         };
470 467
     }
471 468
 
472
-    /**
473
-     * Checks whether the video stream has started for this RemoteVideo instance.
474
-     *
475
-     * @returns {boolean} true if this RemoteVideo has a video stream for which
476
-     * the playback has been started.
477
-     */
478
-    hasVideoStarted() {
479
-        return this.wasVideoPlayed;
480
-    }
481
-
482 469
     /**
483 470
      *
484 471
      * @param {*} stream
@@ -504,10 +491,10 @@ export default class RemoteVideo extends SmallVideo {
504 491
             return;
505 492
         }
506 493
 
507
-        const streamElement = SmallVideo.createStreamElement(stream);
494
+        let streamElement = SmallVideo.createStreamElement(stream);
508 495
 
509 496
         // Put new stream element always in front
510
-        UIUtils.prependChild(this.container, streamElement);
497
+        streamElement = UIUtils.prependChild(this.container, streamElement);
511 498
 
512 499
         $(streamElement).hide();
513 500
 

+ 1
- 1
modules/UI/videolayout/SmallVideo.js Bestand weergeven

@@ -500,7 +500,7 @@ export default class SmallVideo {
500 500
             hasVideo: Boolean(this.selectVideoElement().length),
501 501
             connectionStatus: APP.conference.getParticipantConnectionStatus(this.id),
502 502
             mutedWhileDisconnected: this.mutedWhileDisconnected,
503
-            wasVideoPlayed: this.wasVideoPlayed,
503
+            canPlayEventReceived: this._canPlayEventReceived,
504 504
             videoStream: Boolean(this.videoStream),
505 505
             isVideoMuted: this.isVideoMuted,
506 506
             videoStreamMuted: this.videoStream ? this.videoStream.isMuted() : 'no stream'

Laden…
Annuleren
Opslaan