You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.
Shouldn't we only remove the listener when calling the callback in getScreenId ?
i.e
window.getScreenId=function(callback){// for Firefox:// sourceId == 'firefox'// screen_constraints = {...}if(!!navigator.mozGetUserMedia){callback(null,'firefox',{video: {mozMediaSource: 'window',mediaSource: 'window'}});return;}window.addEventListener('message',onIFrameCallback);functiononIFrameCallback(event){if(!event.data)return;if(event.data.chromeMediaSourceId){// this event listener is no more neededwindow.removeEventListener('message',onIFrameCallback);if(event.data.chromeMediaSourceId==='PermissionDeniedError'){callback('permission-denied');}elsecallback(null,event.data.chromeMediaSourceId,getScreenConstraints(null,event.data.chromeMediaSourceId));}if(event.data.chromeExtensionStatus){// this event listener is no more neededwindow.removeEventListener('message',onIFrameCallback);callback(event.data.chromeExtensionStatus,null,getScreenConstraints(event.data.chromeExtensionStatus));}// this event listener is no more needed//window.removeEventListener('message', onIFrameCallback);}setTimeout(postGetSourceIdMessage,100);};
Best regards
The text was updated successfully, but these errors were encountered:
hello,
I tried to use
getScreenId
in my own application but it needs to be called twice to work. After investigation, I found the culprit, https://github.com/muaz-khan/getScreenId/blob/master/getScreenId.js#L55. The listener on the message is removed a bit too soon.During the first call, the value of
event.data
isBased on the logic, it will remove the listener before triggering the correct value back to my custom code.
During the second call, the value of
event.data
isIf found out that the code works fine in your example (https://github.com/muaz-khan/getScreenId/blob/master/index.html) because you are calling the method
getChromeExtensionStatus
which will simulate the first call.Shouldn't we only remove the listener when calling the
callback
ingetScreenId
?i.e
Best regards
The text was updated successfully, but these errors were encountered: