instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Unable To Access Rear Camera on iPad iOS 11.4.1

Open bm2112 opened this issue 5 years ago • 6 comments

When I launch the website it will show that is displaying the rear camera, but it is actually displaying the front. When I switch over to the front camera, it also displays the front. I've tried everything I could find on the internet to fix this issue and I've had no luck. I've tried making the facingMode "environment", using the code from a couple of forks of this project which supposedly allow the iOS rear camera to work, and changing large portions of the app.js and camera.js myself. I've manually selected camera[1] instead of camera[0] and that will cause it to launch with the other camera selected, but it still displays the front camera.

Has anyone else had an issue with the rear camera on iOS that was unable to solve it using one of the above methods I mentioned? I would greatly appreciate some help. The website works fine for Android and Windows for many browsers, but iOS Safari is giving me nothing but trouble. Thanks

bm2112 avatar Aug 01 '18 22:08 bm2112

As indicated in the Readme, this library only works for mobile browsers that implement WebRTC. IOS browsers currently do not.

Instascan works on non-iOS platforms in any browser that supports the WebRTC/getUserMedia API, which currently includes Chome, Firefox, Opera, and Edge. IE and Safari are not supported.

augustosamame avatar Aug 15 '18 00:08 augustosamame

That is not true. Safari in the newest version of iOS supports WebRTC API. As I said above, it works for the front camera, but not the rear camera.

bm2112 avatar Aug 15 '18 12:08 bm2112

@bm2112 is correct. Much of WebRTC was made available in iOS and Safari 11. Certain things like MediaRecorder are still missing, but it looks like everything used in this library (MediaStreams) should be available.

Maybe the issue should be updated to say "add iOS 11 support" since it's most of the way there anyway.

jvanalst avatar Aug 16 '18 21:08 jvanalst

Has anyone resolved this? I

kibagami-jubei avatar Sep 26 '18 17:09 kibagami-jubei

Yeah, been working on this, I can't get this to work. Trying to go back and re-read threads. I got the front-facing camera to work by adding the latest web RTC adapter and adding the playsinline attribute to the video tag. It can read the cameras but does nothing when swapping to the back camera.

kibagami-jubei avatar Sep 28 '18 23:09 kibagami-jubei

I m not sure how to change this, but when you start the camera is posible to change the camera

var constraints = { video: { facingMode: "environment" //"user" for selfie mode }, audio: false };

function cameraStart() { navigator.mediaDevices .getUserMedia(constraints) .then(function(stream) { track = stream.getTracks()[0]; cameraView.srcObject = stream; }) .catch(function(error) { console.error("Oops. Something is broken.", error); }); }

guidomgs avatar May 08 '20 00:05 guidomgs