|
|
@@ -210,8 +210,8 @@ var RTC = {
|
|
210
|
210
|
var videoStream = this.rtcUtils.createStream(stream, true);
|
|
211
|
211
|
this.localVideo =
|
|
212
|
212
|
this.createLocalStream(videoStream, "video", true, type);
|
|
213
|
|
- // Stop the stream to trigger onended event for old stream
|
|
214
|
|
- oldStream.stop();
|
|
|
213
|
+ // Stop the stream
|
|
|
214
|
+ this.stopMediaStream(oldStream);
|
|
215
|
215
|
|
|
216
|
216
|
APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
|
|
217
|
217
|
},
|
|
|
@@ -219,8 +219,8 @@ var RTC = {
|
|
219
|
219
|
var oldStream = this.localAudio.getOriginalStream();
|
|
220
|
220
|
var newStream = this.rtcUtils.createStream(stream);
|
|
221
|
221
|
this.localAudio = this.createLocalStream(newStream, "audio", true);
|
|
222
|
|
- // Stop the stream to trigger onended event for old stream
|
|
223
|
|
- oldStream.stop();
|
|
|
222
|
+ // Stop the stream
|
|
|
223
|
+ this.stopMediaStream(oldStream);
|
|
224
|
224
|
APP.xmpp.switchStreams(newStream, oldStream, callback, true);
|
|
225
|
225
|
},
|
|
226
|
226
|
isVideoMuted: function (jid) {
|
|
|
@@ -262,6 +262,29 @@ var RTC = {
|
|
262
|
262
|
if(devices.video === true || devices.video === false)
|
|
263
|
263
|
this.devices.video = devices.video;
|
|
264
|
264
|
eventEmitter.emit(RTCEvents.AVAILABLE_DEVICES_CHANGED, this.devices);
|
|
|
265
|
+ },
|
|
|
266
|
+ /**
|
|
|
267
|
+ * A method to handle stopping of the stream.
|
|
|
268
|
+ * One point to handle the differences in various implementations.
|
|
|
269
|
+ */
|
|
|
270
|
+ stopMediaStream: function (mediaStream) {
|
|
|
271
|
+ mediaStream.getAudioTracks().forEach(function (track) {
|
|
|
272
|
+ // stop() not supported with IE
|
|
|
273
|
+ if (track.stop) {
|
|
|
274
|
+ track.stop();
|
|
|
275
|
+ }
|
|
|
276
|
+ });
|
|
|
277
|
+ mediaStream.getVideoTracks().forEach(function (track) {
|
|
|
278
|
+ // stop() not supported with IE
|
|
|
279
|
+ if (track.stop) {
|
|
|
280
|
+ track.stop();
|
|
|
281
|
+ }
|
|
|
282
|
+ });
|
|
|
283
|
+
|
|
|
284
|
+ //
|
|
|
285
|
+ if (mediaStream.stop) {
|
|
|
286
|
+ mediaStream.stop();
|
|
|
287
|
+ }
|
|
265
|
288
|
}
|
|
266
|
289
|
};
|
|
267
|
290
|
|