Browse Source

set the correct active camera number when it starts

kb/add-usage-guide
Trent Larson 4 months ago
parent
commit
9bdb87e9ef
  1. 10
      src/components/PhotoDialog.vue

10
src/components/PhotoDialog.vue

@ -211,6 +211,12 @@ export default class PhotoDialog extends Vue {
if (cameraComponent) {
this.numDevices = (await cameraComponent.devices(["videoinput"])).length;
this.mirror = cameraComponent.facingMode === "user";
// figure out which device is active
const currentDeviceId = cameraComponent.currentDeviceID();
const devices = await cameraComponent.devices(["videoinput"]);
this.activeDeviceNumber = devices.findIndex(
(device) => device.deviceId === currentDeviceId,
);
}
}
@ -218,7 +224,9 @@ export default class PhotoDialog extends Vue {
const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>;
this.activeDeviceNumber = (this.activeDeviceNumber + 1) % this.numDevices;
const devices = await cameraComponent?.devices(["videoinput"]);
cameraComponent?.changeCamera(devices[this.activeDeviceNumber].deviceId);
await cameraComponent?.changeCamera(
devices[this.activeDeviceNumber].deviceId,
);
}
async takeImage(/* payload: MouseEvent */) {

Loading…
Cancel
Save