|
@@ -17,11 +17,35 @@ function implementOnEndedHandling(stream) {
|
17
|
17
|
};
|
18
|
18
|
}
|
19
|
19
|
|
|
20
|
+/**
|
|
21
|
+ * Adds onended/oninactive handler to a MediaStream.
|
|
22
|
+ * @param mediaStream a MediaStream to attach onended/oninactive handler
|
|
23
|
+ * @param handler the handler
|
|
24
|
+ */
|
|
25
|
+function addMediaStreamInactiveHandler(mediaStream, handler) {
|
|
26
|
+ if (mediaStream.addEventListener) {
|
|
27
|
+ // chrome
|
|
28
|
+ if(typeof mediaStream.active !== "undefined")
|
|
29
|
+ mediaStream.oninactive = handler;
|
|
30
|
+ else
|
|
31
|
+ mediaStream.onended = handler;
|
|
32
|
+ } else {
|
|
33
|
+ // themasys
|
|
34
|
+ mediaStream.attachEvent('ended', function () {
|
|
35
|
+ handler(mediaStream);
|
|
36
|
+ });
|
|
37
|
+ }
|
|
38
|
+}
|
|
39
|
+
|
20
|
40
|
/**
|
21
|
41
|
* Represents a single media track (either audio or video).
|
22
|
42
|
* @constructor
|
|
43
|
+ * @param rtc the rtc instance
|
|
44
|
+ * @param stream the stream
|
|
45
|
+ * @param streamInactiveHandler the function that will handle
|
|
46
|
+ * onended/oninactive events of the stream.
|
23
|
47
|
*/
|
24
|
|
-function JitsiTrack(rtc, stream)
|
|
48
|
+function JitsiTrack(rtc, stream, streamInactiveHandler)
|
25
|
49
|
{
|
26
|
50
|
/**
|
27
|
51
|
* Array with the HTML elements that are displaying the streams.
|
|
@@ -44,6 +68,9 @@ function JitsiTrack(rtc, stream)
|
44
|
68
|
if (RTCBrowserType.isFirefox() && this.stream) {
|
45
|
69
|
implementOnEndedHandling(this.stream);
|
46
|
70
|
}
|
|
71
|
+
|
|
72
|
+ if(stream)
|
|
73
|
+ addMediaStreamInactiveHandler(stream, streamInactiveHandler);
|
47
|
74
|
}
|
48
|
75
|
|
49
|
76
|
/**
|