Parcourir la source

Fixes issue with toggling video mute in FF caused by the fact that it has no 'onended' callback handling implemented.

master
paweldomas il y a 10 ans
Parent
révision
c288aa6e84
1 fichiers modifiés avec 22 ajouts et 1 suppressions
  1. 22
    1
      modules/RTC/LocalStream.js

+ 22
- 1
modules/RTC/LocalStream.js Voir le fichier

@@ -1,6 +1,24 @@
1 1
 /* global APP */
2 2
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
3 3
 var RTCEvents = require("../../service/RTC/RTCEvents");
4
+var RTCBrowserType = require("./RTCBrowserType");
5
+
6
+/**
7
+ * This implements 'onended' callback normally fired by WebRTC after the stream
8
+ * is stopped. There is no such behaviour yet in FF, so we have to add it.
9
+ * @param stream original WebRTC stream object to which 'onended' handling
10
+ *               will be added.
11
+ */
12
+function implementOnEndedHandling(stream) {
13
+    var originalStop = stream.stop;
14
+    stream.stop = function () {
15
+        originalStop.apply(stream);
16
+        if (!stream.ended) {
17
+            stream.ended = true;
18
+            stream.onended();
19
+        }
20
+    };
21
+}
4 22
 
5 23
 function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
6 24
     this.stream = stream;
@@ -21,9 +39,12 @@ function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
21 39
         };
22 40
     }
23 41
 
24
-    this.stream.onended = function() {
42
+    this.stream.onended = function () {
25 43
         self.streamEnded();
26 44
     };
45
+    if (RTCBrowserType.isFirefox()) {
46
+        implementOnEndedHandling(this.stream);
47
+    }
27 48
 }
28 49
 
29 50
 LocalStream.prototype.streamEnded = function () {

Chargement…
Annuler
Enregistrer