Skip to content

Commit

Permalink
Merge pull request #7309 from TheThingsNetwork/fix/video-feed
Browse files Browse the repository at this point in the history
Fix video feed on firefox
  • Loading branch information
mjamescompton authored Sep 16, 2024
2 parents 4efe7ca + ab04e15 commit 70e1ede
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/webui/components/qr/input/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ const Camera = props => {
}
}, [cameras])

const setDeviceIdFromStream = useCallback(userStream => {
const videoTracks = userStream.getVideoTracks()

if (videoTracks.length > 0) {
const { deviceId } = videoTracks[0].getSettings()
setDeviceId(deviceId)
}
}, [])
const setDeviceIdFromStream = useCallback(
userStream => {
const videoTracks = userStream.getVideoTracks()
if (videoTracks.length > 0) {
const { deviceId } = videoTracks[0].getSettings()
if (deviceId) {
setDeviceId(deviceId)
} else if (cameras.length > 0) {
setDeviceId(cameras[0].deviceId)
}
}
},
[cameras],
)

useEffect(() => {
setHasFrontCamera(cameras.some(device => device.label.toLowerCase().includes('front')))
Expand Down

0 comments on commit 70e1ede

Please sign in to comment.