question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set 'back camera' as the default camera in IOS 13

See original GitHub issue

Describe the bug I have tried to set the ‘Back camera’ of the mobile device (both android and Iphone) as the default camera of the scanner. I have also tried the solution given in the following link:

Reference link

But am unable to set back camera as the default camera in IOS 13. and i also want to know how to identify ‘back camera’ from the available devices? as of now i am identifying it based on the label property of the device. But i want to know if there is any other way to identify that.

HTML code:

<zxing-scanner #scanner class="test-class" start="true" (scanSuccess)="handleQrCodeResult($event)" cssClass="small-video"></zxing-scanner>

TS Code:

import { Component, VERSION, ViewChild } from '@angular/core';

import { ZXingScannerComponent } from '@zxing/ngx-scanner';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ngVersion = VERSION.full;

  @ViewChild('scanner')
  scanner: ZXingScannerComponent;

  hasCameras = false;
  hasPermission: boolean;
  qrResultString: string;

  availableDevices: MediaDeviceInfo[];
  selectedDevice: MediaDeviceInfo;

  ngOnInit(): void {

    this.scanner.camerasFound.subscribe((devices: MediaDeviceInfo[]) => {
      this.hasCameras = true;

      console.log('Devices: ', devices);
      this.availableDevices = devices;
      this.setDeviceDefaultCamera();
    });
  }

  handleQrCodeResult(resultString: string) {
    console.log('Result: ', resultString);
    this.qrResultString = resultString;
  }

  onDeviceSelectChange(selectedValue) {
    console.log('Selection changed: ', selectedValue);
    this.scanner.device = selectedValue;
  }

  setDeviceDefaultCamera() {
    for (let index = 0; index < this.availableDevices.length; index++) {
      if (this.availableDevices[index].label.toLowerCase().includes('front') || this.availableDevices[index].label.toLowerCase().includes('rear')) {
        this.scanner.device = this.availableDevices[index];
      }
    }
  }
}

Smartphone (please complete the following information):

  • Device: [ iPhone11 pro]
  • OS: [ iOS 13.3.1]
  • Browser [ safari]
  • Version of ngx scanner = 1.4.0

Additional context i am currently using angular 6 and ngx scanner version 1.4. And testing in Iphone and Android devices.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
odahcamcommented, Apr 30, 2020

Please, setup a demo and open another issue @Xenoage , setting the value for device should work.

0reactions
shreya-sawardekarcommented, Oct 22, 2021

I am facing the same issue. Even though I set the device property, it is not picking up the correct camera.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change advanced camera settings on iPhone - Apple Support
Lens Correction is on by default. To turn off Lens Correction, go to Settings > Camera, then turn off Lens Correction. Turn Scene...
Read more >
iPhone 13/13 Pro: How to Set Camera Default Photographic ...
Learn how you can set camera default Photographic styles to Standard, Rich Contrast, Cool, Warm, Vibrant on iPhone 13 / iPhone 13 Pro/Mini....
Read more >
How to Reset iPhone Camera Settings and Change Its ...
In this article, you will learn how to reset iPhone camera and how to change the advanced settings to enhance your photography skills....
Read more >
How to Set the Default Camera Mode on iPhone | OSXDaily
You will need iOS 10.2 or later installed on the iPhone or iPad to have the preserve camera settings feature, which allows you...
Read more >
10 Ways to Fix It When an iPhone Camera is Not Working
How to Fix iPhone Camera Not Working Due to Software · Test with FaceTime. Perhaps the quickest way to test both front and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found