forked from trent_larson/crowd-funder-for-time-pwa
set the correct active camera number when it starts
This commit is contained in:
@@ -211,6 +211,12 @@ export default class PhotoDialog extends Vue {
|
|||||||
if (cameraComponent) {
|
if (cameraComponent) {
|
||||||
this.numDevices = (await cameraComponent.devices(["videoinput"])).length;
|
this.numDevices = (await cameraComponent.devices(["videoinput"])).length;
|
||||||
this.mirror = cameraComponent.facingMode === "user";
|
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>;
|
const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>;
|
||||||
this.activeDeviceNumber = (this.activeDeviceNumber + 1) % this.numDevices;
|
this.activeDeviceNumber = (this.activeDeviceNumber + 1) % this.numDevices;
|
||||||
const devices = await cameraComponent?.devices(["videoinput"]);
|
const devices = await cameraComponent?.devices(["videoinput"]);
|
||||||
cameraComponent?.changeCamera(devices[this.activeDeviceNumber].deviceId);
|
await cameraComponent?.changeCamera(
|
||||||
|
devices[this.activeDeviceNumber].deviceId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async takeImage(/* payload: MouseEvent */) {
|
async takeImage(/* payload: MouseEvent */) {
|
||||||
|
|||||||
Reference in New Issue
Block a user