QRScanJS
QRScanJS copied to clipboard
MediaStreamTrack.getSources is deprecated!!
https://www.chromestatus.com/feature/4765305641369600
Use:
navigator.mediaDevices.enumerateDevices()
Thanks for reporting. However, currently chrome also doesn't seem to support any different API (e.g. it doesn't support facingMode in mediaDevices.getUserMedia and it doesn't have a full implementation of the new mediaDevices.getUserMedia). Considering these circumstances, I don't think I can update just yet, I have to keep using the deprecated API.
I uploaded my experimental changes to the update_mediadevices branch. It works fine in firefox for me, but doesn't properly select the back camera on chrome on android (which is just what the code is supposed to do).
Hi @Jeija I am using QRScan in my PWA application. https://qrcodescan.in.
navigator.mediaDevices.enumerateDevices() is working fine in firefox, chrome, opera.
There still is the problem of camera selection on mobile devices though. Chrome on Android still doesn't support the facingMode constraint, which is what we need to tell Chrome to use the rear, environment-facing camera (similar to what the W3C specification says in https://w3c.github.io/mediacapture-main/getusermedia.html#interface-definition, Example 9).
If I understand the code for https://qrcodescan.in correctly, you always assume that the second camera listed by navigator.mediaDevices.enumerateDevices() is the environment-facing camera. That may work in most cases, but it doesn't cover all devices. Even webrtc-adapter hasn't solved this issue completely, they also need to fall back to using the last camera in the list (see https://github.com/webrtc/adapter/blob/master/src/js/chrome/getusermedia.js).
This means I can only remove MediaStreamTrack.getSources() without loosing functionality when https://bugs.chromium.org/p/chromium/issues/detail?id=290161 is resolved. Otherwise, I'd much rather use a deprecated API than dropping functionality.
As soon as the Chromium bug is resolved and clients are updated, I will upgrade to the code on the https://github.com/Jeija/QRScanJS/tree/update_mediadevices branch and switch to the new API.
It seems like the "deprecated" status has finally turned into removed and the example no longer works on Chrome, with a console error saying that MediaStreamTrack is not a function. @gokulkrishh perhaps you could make a pull request with the way that worked in your PWA?
@abagh0703 Sure. let me see what i can do.