Last active
May 29, 2024 11:28
-
-
Save CezaryDanielNowak/1afedcd47f4bc5f093e08329b7ca7dbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const realGetUserMedia = navigator.mediaDevices.getUserMedia; | |
const realApplyConstraints = MediaStreamTrack.prototype.applyConstraints; | |
function successHandler(...args) { | |
try { | |
const track = args[0].getVideoTracks()[0]; | |
console.log('π₯π₯π₯', track.label, 'camera access granted.\n', track.getSettings()); | |
} catch(err) { | |
console.warn('π₯π₯π₯ error', err); | |
} | |
} | |
function failHandler(...args) { | |
console.warn('π₯π₯π₯ fail handler', args); | |
} | |
navigator.mediaDevices.getUserMedia = function (...args) { | |
console.log('π₯π₯π₯ getUserMedia', ...args); | |
const result = realGetUserMedia.apply(this, args); | |
result.then(successHandler, failHandler); | |
return result; | |
}; | |
MediaStreamTrack.prototype.applyConstraints = function(...args) { | |
console.log('π₯π₯π₯ applyConstraints', ...args); | |
return realApplyConstraints.apply(this, args); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment