diff --git a/src/components/PhotoDialog.vue b/src/components/PhotoDialog.vue index ec3456a8b..b28f82d03 100644 --- a/src/components/PhotoDialog.vue +++ b/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; 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 */) {