Description
I opened the preview screen on two browsers, Chrome and Edge (with two USB cameras, referred to as Cam 1 and Cam 2).
First, I accessed Chrome, and Cam 1 was displayed.
Then, I accessed Edge, but Cam 1 did not appear và countered an error. I tried switching to Cam 2 using switchCamera but encountered an error.
However, in Chrome, switching to Cam 2 using switchCamera worked fine.
When I exit the Chrome browser preview screen, the Edge browser camera works normally.
Browser Console Error
Error when Cam 1 did not appear in Edge: DOMException: Could not start video source
Error when switching to Cam 2 in Edge: {“stack”: “Error: VideoNotStartedError”, “message”: “VideoNotStartedError”}
Which Web Video SDK version?
1.11.6
To Reproduce(If applicable)
Steps to reproduce the behavior:
Go to the preview screen on the Chrome browser, and Cam 1 works.
Go to the preview screen on the Edge browser, and Cam 1 does not work.
In the Edge browser, call the switchCamera function to switch to Cam 2, and Cam 2 does not work.
In the Chrome browser, call the switchCamera function to switch to Cam 2, and Cam 2 works.
Device (please complete the following information):
Device: Windows
OS: Windows 10 Version 22H2
Browser: Chrome and Edge
Browser Version: Chrome version 126.0.6478.127 (Official Build (Official Build) (64-bit) and Edge version 126.0.2592.87 (Official build) (64-bit)
Hey @vic.yang,
Thank you for your response, and I apologize for my delayed reply.
I am currently in the preview screen using localTrack to start, so the suggestion you provided doesn’t seem to apply.
I’ll describe my issue in more detail:
Edge browser enters the preview screen using Camera 1 => OK.
Chrome browser using Camera 1 => encountered the error “Device in use” (This is a limitation of Windows).
Chrome browser, I switch to Camera 2 (by recreating localTrack before starting the camera) => encountered the error “Could not start video source.”
Edge browser switches between two cameras and works fine. Only when I stop the camera in Edge does Chrome become able to use the camera (both cameras work => then Edge encounters the same error that Chrome initially did).
The above issue also occurs when both browsers enter the preview screen, each selecting a different camera (the browser that enters first gets to use the camera).
I don’t know if there is something wrong with the way I’m handling this?
Additionally, could you please explain why I don’t encounter the “Device in use” error when starting the camera with a virtual background?
It might be NotReadableError. Could you test the camera with WebRTC official sample.
why I don’t encounter the “Device in use” error when starting the camera with a virtual background
In the virtual background implementation, if the device is occupied, we will fall back to the default device (which is specified by the system). That’s why you will not encounter the “Device in use” error.
However, this fallback handling has a side effect because it is not the device you specified.
That’s correct, both the “Device in use” and “Could not start video source” messages are associated with the NotReadableError.
Could you test the camera with WebRTC official sample.
I checked on WebRTC and encountered the same error.
According to the description of the NotReadableError, does it mean that there’s no way for each browser to use a different camera?
In the virtual background implementation, if the device is occupied, we will fall back to the default device (which is specified by the system).
When falls back to the default device, it still uses the virtual background, right? If that’s the case, then no error would be received if the device is occupied.
That’s why you will not encounter the “Device in use” error.
Is there a way I can handle the case where the camera starts with a virtual background to warn the user?
Additionally, Is there a way to determine the default device specified by the system?
does it mean that there’s no way for each browser to use a different camera?
It depends on the device and OS, we tested the similar case on our device, it works without error.
When falls back to the default device, it still uses the virtual background, right? If that’s the case, then no error would be received if the device is occupied.
The camera will not be the same one, browser will prioritize selecting an unoccupied device if one is available.
Is there a way I can handle the case where the camera starts with a virtual background to warn the user?
Do you mean giving a warning when an incorrect camera is selected?
Currently, no selected camera device id for Local video track feature.
Is there a way to determine the default device specified by the system?
When no other application is using the camera, the first time the camera is started, it uses the default device set in your system.
However, once this default device is occupied, the choice of which camera to use depends on the browser.
It depends on the device and OS, we tested the similar case on our device, it works without error.
In my case, I am using two USB cameras (Logitech and HIKVISION) and two browsers: Chrome and Edge
Chrome: Version 127.0.6533.99 (Official Build) (64-bit)
Edge: Version 126.0.2592.102 (Official Build) (64-bit)
I tested it on WebRTC and encountered the same error.
Do you mean giving a warning when an incorrect camera is selected?
No, when the user selects the camera in virtual background mode but the camera doesn’t turn on (Because the camera is being occupied). In this case, I want to warn the user ‘Your camera is being used by other apps. Close those apps and try again.’
I still refer to the preview feature.
When I start with imageUrl, I don’t receive any errors. It’s only when I start without using the virtual background that I encounter an error.
I still want to confirm with you that if I use the 2 USB cameras we discussed earlier, getting the NotReadableError when using the second camera will depend on the OS and the device. (We won’t be able to control this behavior)