Skip to content

Commit

Permalink
fix: switch camera not working
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Oct 21, 2024
1 parent c79cb3d commit 96afa1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions frontend/src/components/FilesUploader/FilesUploaderArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,29 @@ function onFileInput(event) {
const video = ref(null)
const facingMode = ref('environment')
const stream = ref(null)
async function startCamera() {
showCamera.value = true
let stream = await navigator.mediaDevices.getUserMedia({
stream.value = await navigator.mediaDevices.getUserMedia({
video: {
facingMode: facingMode.value,
},
audio: false,
})
video.value.srcObject = stream
video.value.srcObject = stream.value
}
function stopStream() {
stream.value.getTracks().forEach((track) => track.stop())
showCamera.value = false
cameraImage.value = null
}
function switchCamera() {
facingMode.value = facingMode.value === 'environment' ? 'user' : 'environment'
stopStream()
startCamera()
}
Expand Down

0 comments on commit 96afa1f

Please sign in to comment.