Browse Source

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

master
paweldomas 10 years ago
parent
commit
c288aa6e84
1 changed files with 22 additions and 1 deletions
  1. 22
    1
      modules/RTC/LocalStream.js

+ 22
- 1
modules/RTC/LocalStream.js View File

1
 /* global APP */
1
 /* global APP */
2
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
2
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
3
 var RTCEvents = require("../../service/RTC/RTCEvents");
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
 function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
23
 function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
6
     this.stream = stream;
24
     this.stream = stream;
21
         };
39
         };
22
     }
40
     }
23
 
41
 
24
-    this.stream.onended = function() {
42
+    this.stream.onended = function () {
25
         self.streamEnded();
43
         self.streamEnded();
26
     };
44
     };
45
+    if (RTCBrowserType.isFirefox()) {
46
+        implementOnEndedHandling(this.stream);
47
+    }
27
 }
48
 }
28
 
49
 
29
 LocalStream.prototype.streamEnded = function () {
50
 LocalStream.prototype.streamEnded = function () {

Loading…
Cancel
Save