We can request a media stream to a screen or windows via navigator.mediaDevices.getDisplayMedia()
. However, this immediately prompts the user to decide which kind of capturing to use. I need to check if the browser/platform even support screen capturing.
Of course, it is possible to check for 'getDisplayMedia' in navigator.mediaDevices
, but this just tells us if the API is supported by the browser. In particular, on FF and Chrome on Android, the API is defined and I can call getDisplayMedia()
, but it always immediately returns a NotAllowedError
error (which is to be expected: according to caniuse, the mobile browsers do not yet support getDisplayMedia
.)
Next, I tried checking navigator.mediaDevices.getSupportedConstraints()
. However, my mobile FF returns the exact same object as my desktop FF. In particular, navigator.mediaDevices.getSupportedConstraints().mediaSource
is true
in both cases. Finally, the data returned by navigator.mediaDevices.enumerateDevices()
does not help me either. I only get a device and group ID which I cannot interpret in any way (right?).
Is it possible to detect whether or not screen capture via getDisplayMedia
is supported beforehand?
(Note: this Q&A seems fairly similar, but is about getUserMedia
and is already quite old)