Fixes Uncaught TypeError: mediaStream.detachEvent on stopping desktop sharing.

This commit is contained in:
damencho 2015-12-04 11:30:11 -06:00
parent 09a509400f
commit 5f6bba435c
1 changed files with 12 additions and 12 deletions

View File

@ -300,18 +300,18 @@ var RTC = {
* @param handler the handler
*/
addMediaStreamInactiveHandler: function (mediaStream, handler) {
if (mediaStream.addEventListener) {
// chrome
if(typeof mediaStream.active !== "undefined")
mediaStream.oninactive = handler;
else
mediaStream.onended = handler;
} else {
if(RTCBrowserType.isTemasysPluginUsed()) {
// themasys
mediaStream.attachEvent('ended', function () {
handler(mediaStream);
});
}
else {
if(typeof mediaStream.active !== "undefined")
mediaStream.oninactive = handler;
else
mediaStream.onended = handler;
}
},
/**
* Removes onended/inactive handler.
@ -319,15 +319,15 @@ var RTC = {
* @param handler the handler to remove.
*/
removeMediaStreamInactiveHandler: function (mediaStream, handler) {
if (mediaStream.removeEventListener) {
// chrome
if(RTCBrowserType.isTemasysPluginUsed()) {
// themasys
mediaStream.detachEvent('ended', handler);
}
else {
if(typeof mediaStream.active !== "undefined")
mediaStream.oninactive = null;
else
mediaStream.onended = null;
} else {
// themasys
mediaStream.detachEvent('ended', handler);
}
}
};