提交 d5a06524 authored 作者: shashi kumar's avatar shashi kumar 提交者: Mike Jerris

FS-11960: [js] replaces all deprecated js methods for FF warnings

上级 1c80a83d
...@@ -297,18 +297,9 @@ ...@@ -297,18 +297,9 @@
} }
if (self.localStream && !self.options.useStream) { if (self.localStream && !self.options.useStream) {
if(typeof self.localStream.stop == 'function') {
self.localStream.stop();
} else {
if (self.localStream.active){
var tracks = self.localStream.getTracks(); var tracks = self.localStream.getTracks();
console.log(tracks); console.log("Stopping localStream tracks:", tracks);
tracks.forEach(function(track, index){ tracks.forEach(function(track){ track.stop() })
console.log(track);
track.stop();
})
}
}
self.localStream = null; self.localStream = null;
} }
...@@ -317,18 +308,9 @@ ...@@ -317,18 +308,9 @@
} }
if (self.options.localVideoStream && !self.options.useStream) { if (self.options.localVideoStream && !self.options.useStream) {
if(typeof self.options.localVideoStream.stop == 'function') {
self.options.localVideoStream.stop();
} else {
if (self.options.localVideoStream.active){
var tracks = self.options.localVideoStream.getTracks(); var tracks = self.options.localVideoStream.getTracks();
console.log(tracks); console.log("Stopping localVideoStream tracks:", tracks);
tracks.forEach(function(track, index){ tracks.forEach(function(track){ track.stop() })
console.log(track);
track.stop();
})
}
}
} }
if (self.peer) { if (self.peer) {
...@@ -785,18 +767,17 @@ ...@@ -785,18 +767,17 @@
} }
} }
peer.onaddstream = function(event) { // peer.onaddstream = function(event) { // OLD API
var remoteMediaStream = event.stream; peer.ontrack = function(event) {
console.log('Peer Track', event)
// var remoteMediaStream = event.stream;
var remoteMediaStream = event.streams[0];
// onRemoteStreamEnded(MediaStream)
remoteMediaStream.oninactive = function () { remoteMediaStream.oninactive = function () {
if (options.onRemoteStreamEnded) options.onRemoteStreamEnded(remoteMediaStream); if (options.onRemoteStreamEnded) options.onRemoteStreamEnded(remoteMediaStream);
}; };
// onRemoteStream(MediaStream)
if (options.onRemoteStream) options.onRemoteStream(remoteMediaStream); if (options.onRemoteStream) options.onRemoteStream(remoteMediaStream);
//console.debug('on:add:stream', remoteMediaStream);
}; };
//var constraints = options.constraints || { //var constraints = options.constraints || {
...@@ -959,16 +940,13 @@ ...@@ -959,16 +940,13 @@
}, },
stop: function() { stop: function() {
peer.close(); if (options.attachStream instanceof MediaStream) {
if (options.attachStream) { var tracks = options.attachStream.getTracks();
if(typeof options.attachStream.stop == 'function') { tracks.forEach(function(track){ track.stop() })
options.attachStream.stop(); options.attachStream = null
} else {
options.attachStream.active = false;
}
} }
peer.close();
} }
}; };
} }
...@@ -1060,7 +1038,6 @@ ...@@ -1060,7 +1038,6 @@
console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options); console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options);
}); });
} }
$.FSRTC.resSupported = function(w, h) { $.FSRTC.resSupported = function(w, h) {
for (var i in $.FSRTC.validRes) { for (var i in $.FSRTC.validRes) {
if ($.FSRTC.validRes[i][0] == w && $.FSRTC.validRes[i][1] == h) { if ($.FSRTC.validRes[i][0] == w && $.FSRTC.validRes[i][1] == h) {
...@@ -1116,13 +1093,11 @@ ...@@ -1116,13 +1093,11 @@
} }
getUserMedia({ getUserMedia({
constraints: { constraints: { audio: ttl++ == 0, video: video },
audio: ttl++ == 0,
video: video
},
onsuccess: function(e) { onsuccess: function(e) {
e.getTracks().forEach(function(track) {track.stop();}); e.getTracks().forEach(function(track) { track.stop() });
console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);}, console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);
},
onerror: function(e) {console.warn( w + "x" + h + " not supported."); checkRes(cam, func);} onerror: function(e) {console.warn( w + "x" + h + " not supported."); checkRes(cam, func);}
}); });
} }
...@@ -1153,14 +1128,9 @@ ...@@ -1153,14 +1128,9 @@
$.FSRTC.checkPerms = function (runtime, check_audio, check_video) { $.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
getUserMedia({ getUserMedia({
constraints: { constraints: { audio: check_audio, video: check_video },
audio: check_audio,
video: check_video,
},
onsuccess: function(e) { onsuccess: function(e) {
e.getTracks().forEach(function(track) { track.stop() });
e.getTracks().forEach(function(track) {track.stop();});
console.info("media perm init complete"); console.info("media perm init complete");
if (runtime) { if (runtime) {
setTimeout(runtime, 100, true); setTimeout(runtime, 100, true);
...@@ -1171,9 +1141,7 @@ ...@@ -1171,9 +1141,7 @@
console.error("error, retesting with audio params only"); console.error("error, retesting with audio params only");
return $.FSRTC.checkPerms(runtime, check_audio, false); return $.FSRTC.checkPerms(runtime, check_audio, false);
} }
console.error("media perm init error"); console.error("media perm init error");
if (runtime) { if (runtime) {
runtime(false) runtime(false)
} }
......
...@@ -2837,16 +2837,15 @@ ...@@ -2837,16 +2837,15 @@
has_video++; has_video++;
} }
} }
navigator.mediaDevices.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)})
navigator.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)}, .then(function(stream) {
function(stream) {
Xstream = stream; Xstream = stream;
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError); navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);
}, })
function(err) { .catch(function(err) {
console.log("The following error occurred: " + err.name); console.log("The following error occurred: " + err.name);
} });
);
} }
navigator.mediaDevices.enumerateDevices().then(checkTypes).catch(handleError); navigator.mediaDevices.enumerateDevices().then(checkTypes).catch(handleError);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论