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

This commit is contained in:
shashi kumar 2018-11-06 12:35:59 -06:00 committed by Mike Jerris
parent 1c80a83d57
commit d5a065243f
2 changed files with 74 additions and 107 deletions

View File

@ -297,38 +297,20 @@
}
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();
console.log(tracks);
tracks.forEach(function(track, index){
console.log(track);
track.stop();
})
}
}
var tracks = self.localStream.getTracks();
console.log("Stopping localStream tracks:", tracks);
tracks.forEach(function(track){ track.stop() })
self.localStream = null;
}
if (self.options.localVideo) {
deactivateLocalVideo(self.options.localVideo);
deactivateLocalVideo(self.options.localVideo);
}
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();
console.log(tracks);
tracks.forEach(function(track, index){
console.log(track);
track.stop();
})
}
}
if (self.options.localVideoStream && !self.options.useStream) {
var tracks = self.options.localVideoStream.getTracks();
console.log("Stopping localVideoStream tracks:", tracks);
tracks.forEach(function(track){ track.stop() })
}
if (self.peer) {
@ -785,18 +767,17 @@
}
}
peer.onaddstream = function(event) {
var remoteMediaStream = event.stream;
// peer.onaddstream = function(event) { // OLD API
peer.ontrack = function(event) {
console.log('Peer Track', event)
// var remoteMediaStream = event.stream;
var remoteMediaStream = event.streams[0];
// onRemoteStreamEnded(MediaStream)
remoteMediaStream.oninactive = function () {
if (options.onRemoteStreamEnded) options.onRemoteStreamEnded(remoteMediaStream);
};
// onRemoteStream(MediaStream)
if (options.onRemoteStream) options.onRemoteStream(remoteMediaStream);
//console.debug('on:add:stream', remoteMediaStream);
};
//var constraints = options.constraints || {
@ -959,16 +940,13 @@
},
stop: function() {
peer.close();
if (options.attachStream) {
if(typeof options.attachStream.stop == 'function') {
options.attachStream.stop();
} else {
options.attachStream.active = false;
}
if (options.attachStream instanceof MediaStream) {
var tracks = options.attachStream.getTracks();
tracks.forEach(function(track){ track.stop() })
options.attachStream = null
}
peer.close();
}
};
}
@ -1060,7 +1038,6 @@
console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options);
});
}
$.FSRTC.resSupported = function(w, h) {
for (var i in $.FSRTC.validRes) {
if ($.FSRTC.validRes[i][0] == w && $.FSRTC.validRes[i][1] == h) {
@ -1115,14 +1092,12 @@
video = assignMediaIdToConstraint(cam, video);
}
getUserMedia({
constraints: {
audio: ttl++ == 0,
video: video
},
getUserMedia({
constraints: { audio: ttl++ == 0, video: video },
onsuccess: function(e) {
e.getTracks().forEach(function(track) {track.stop();});
console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
e.getTracks().forEach(function(track) { track.stop() });
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);}
});
}
@ -1152,33 +1127,26 @@
}
$.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
getUserMedia({
constraints: {
audio: check_audio,
video: check_video,
},
onsuccess: function(e) {
e.getTracks().forEach(function(track) {track.stop();});
console.info("media perm init complete");
if (runtime) {
getUserMedia({
constraints: { audio: check_audio, video: check_video },
onsuccess: function(e) {
e.getTracks().forEach(function(track) { track.stop() });
console.info("media perm init complete");
if (runtime) {
setTimeout(runtime, 100, true);
}
}
},
onerror: function(e) {
if (check_video && check_audio) {
console.error("error, retesting with audio params only");
return $.FSRTC.checkPerms(runtime, check_audio, false);
}
console.error("media perm init error");
if (runtime) {
runtime(false)
}
}
});
onerror: function(e) {
if (check_video && check_audio) {
console.error("error, retesting with audio params only");
return $.FSRTC.checkPerms(runtime, check_audio, false);
}
console.error("media perm init error");
if (runtime) {
runtime(false)
}
}
});
}
})(jQuery);

View File

@ -2837,16 +2837,15 @@
has_video++;
}
}
navigator.mediaDevices.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)})
.then(function(stream) {
Xstream = stream;
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);
})
.catch(function(err) {
console.log("The following error occurred: " + err.name);
});
navigator.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)},
function(stream) {
Xstream = stream;
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);
},
function(err) {
console.log("The following error occurred: " + err.name);
}
);
}
navigator.mediaDevices.enumerateDevices().then(checkTypes).catch(handleError);