Publish Webcam after connect webcam device

how to use webcam publish when connected webcamdevice?
I with the following code snippet:
navigator.mediaDevices.ondevicechange = async (event) => {
navigator.mediaDevices.enumerateDevices()
.then((devices) => {
devices.forEach(async(device, i) => {
if (device.kind === ‘videoinput’) {
await oVSessionService.publishWebcam();
}
});
});
}
but not publish video and get error duplicate init
please help me