Skip to content

Commit

Permalink
fix(web): stop streaming after check permission
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocroh committed Jun 2, 2024
1 parent 5ae80b0 commit 15a8128
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions apps/web/hooks/useUserMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export const useUserMedia = () => {

const checkPermission = useCallback(async () => {
try {
await navigator.mediaDevices.getUserMedia({
const _stream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: true,
})
setAccessGranted(true)
stopStreaming(_stream)

return {
video: true,
audio: true,
Expand Down Expand Up @@ -200,12 +202,15 @@ export const useUserMedia = () => {
}

if (!audio && !video && !audioOutput) {
audio = _devices.find((device) => device.kind === 'audioinput')
?.deviceId
video = _devices.find((device) => device.kind === 'videoinput')
?.deviceId
audioOutput = _devices.find((device) => device.kind === 'audiooutput')
?.deviceId
audio = _devices.find(
(device) => device.kind === 'audioinput'
)?.deviceId
video = _devices.find(
(device) => device.kind === 'videoinput'
)?.deviceId
audioOutput = _devices.find(
(device) => device.kind === 'audiooutput'
)?.deviceId
}

if (video) {
Expand Down

0 comments on commit 15a8128

Please sign in to comment.