Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
set device(device: MediaDeviceInfo | null) {
if (!device && device !== null) {
throw new ArgumentException('The `device` must be a valid MediaDeviceInfo or null.');
}
if (this.isCurrentDevice(device)) {
console.warn('Setting the same device is not allowed.');
return;
}
if (this.isAutostarting) {
// do not allow setting devices during auto-start, since it will set one and emit it.
console.warn('Avoid setting a device during auto-start.');
return;
}
if (!this.hasPermission) {
console.warn('Permissions not set yet, waiting for them to be set to apply device change.');
// this.permissionResponse
set device(device: MediaDeviceInfo | null) {
if (this.isAlreadyDefinedDevice(device)) {
return;
}
// in order to change the device the codeReader gotta be reseted
this.scannerStop();
if (!device && device !== null) {
throw new ArgumentException('The `device` must be a valid MediaDeviceInfo or null.');
}
if (!!device) {
// starts if enabled and set the current device
this.startScan(device);
}
}