From 5f6bba435c2ba0ff566bca5ba575ab7e2fb0432e Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 4 Dec 2015 11:30:11 -0600 Subject: [PATCH] Fixes Uncaught TypeError: mediaStream.detachEvent on stopping desktop sharing. --- modules/RTC/RTC.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/RTC/RTC.js b/modules/RTC/RTC.js index 790e81708..79d212f21 100644 --- a/modules/RTC/RTC.js +++ b/modules/RTC/RTC.js @@ -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); } } };