Skip to content

Commit

Permalink
feat(ui): selected camera
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww committed Oct 3, 2024
1 parent 2c6b5bf commit f05d1b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ const { devices } = useDevicesList({
const cameraSignalStatus = ref(CameraSignalStatus.Waiting)
const cameras = computed(() => devices.value.filter(i => i.kind === 'videoinput'))
const selectedCamera = ref(cameras.value[0]?.deviceId)
const selectedCamera = useLocalStorage('qrs-selected-camera', cameras.value[0]?.deviceId)
watchEffect(() => {
if (!selectedCamera.value)
selectedCamera.value = cameras.value[0]?.deviceId
})
watch(cameras, () => {
if (selectedCamera.value && cameras.value.filter(i => i.deviceId === selectedCamera.value).length === 0)
selectedCamera.value = ''
})
// const results = defineModel<Set<string>>('results', { default: new Set() })
let stream: MediaStream | undefined
Expand Down Expand Up @@ -97,6 +102,8 @@ function disconnectCamera() {
async function connectCamera() {
try {
cameraSignalStatus.value = CameraSignalStatus.Waiting
stream = await navigator.mediaDevices.getUserMedia({
audio: false,
video: {
Expand Down

0 comments on commit f05d1b6

Please sign in to comment.