Ngx-scanner: What happened with getDeviceById method?

Created on 22 May 2019  路  9Comments  路  Source: zxing-js/ngx-scanner

Hi there,

I was using the 1.3.0 version and today I have updated it to 1.5.0. After that, I have found that the getDeviceById method from the ZXingScannerComponent class does not exists anymore. So my question is what happened with this method? Have you changed the name or removed it? If it has been removed, is there any other method to get the device ID?

I did my code following your plunker demo (https://embed.plnkr.co/MN4riU/) and it is something like this:

  <zxing-scanner #scanner start="true" [device]="selectedDevice"
                 (scanSuccess)="handleQrCodeResult($event)"
                 (scanError)="handleQrCodeResult($event, true)"
                 (camerasNotFound)="camerasNotFound($event)"
                 (camerasFound)="camerasFound($event)"
                 (permissionResponse)="permissionResponse($event)"></zxing-scanner>
@Component({
  selector: 'app-qr-reader',
  templateUrl: './qr-reader.component.html',
  styleUrls: ['./qr-reader.component.scss']
})
export class QrReaderComponent implements OnInit {
  @ViewChild('scanner') scanner: ZXingScannerComponent;

  onDeviceSelectChange(selectedValue: string) {
      this.selectedDevice = this.scanner.getDeviceById(selectedValue);
  }

  [..]

Thanks for your help!

question

Most helpful comment

Yes, my fault. It happens that I didn't remember that there was such changes, it was a long time since I coded this release. Looks like a lot more people is using this lib now so I gotta be careful.

All 9 comments

same problem here. I used 1.3 version for now

I have the same problem here. I have used version 1.3 for now. I hope the team will fix it soon :)

team: me (hey!) 馃槅

Get device by ID is out, it was removed from 1.3 to 1.5. You can still filter devices by ID like this:

    this.scanner.camerasFound.subscribe((devices: MediaDeviceInfo[]) => {
      // selects the devices's back camera by default
      for (const device of devices) {
          if (device.id === myDeviceId) {
            return device;
          }
      }
    });

Thank you for your answer, we will change our code accordingly. Just a tip: It would be wonderful if you publish a list of changes within the next releases, in that way we can figure out if there is something we should change.

Regards.

Yes, my fault. It happens that I didn't remember that there was such changes, it was a long time since I coded this release. Looks like a lot more people is using this lib now so I gotta be careful.

Thank you very much for your reply. I based myself on an example that you published in plunker.

One last request regarding the library, could it be possible to update the demo example?
https://embed.plnkr.co/MN4riU/
Thank you.

That Plunkr example is not maintained anymore, so for future updates, you should keep an eye at the StackBlitz one. Thanks.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattiaskagstrom picture mattiaskagstrom  路  8Comments

JKing-B16 picture JKing-B16  路  6Comments

ramdanegie picture ramdanegie  路  6Comments

rastajpa picture rastajpa  路  7Comments

tearforfear007 picture tearforfear007  路  6Comments