switchDevice() error Failed to GetUserMedia "-" NotReadableError "- 0 -" 开始捕获视频轨道失败

switchDevice() error Failed to GetUserMedia "–" NotReadableError "– 0 –" Failed starting capture of a video track

我在 switchDevice() 中收到以下错误 可能的问题是什么? Failed to GetUserMedia "–" NotReadableError "– 0 –" Failed starting capture of a video track 此错误可能发生也可能不发生

我得到以下建议

Make sure that if you are switching cameras to stop any existing tracks. Stop all tracks in an active stream before acquiring a new one.

我尝试了以下并解决了

## OK
navigator.mediaDevices.getUserMedia(video: true,audio: true).then((mediaStream) =>
        mediaStream.getTracks().forEach((track) => track.stop())
)
## NG
localStream.getVideoTrack().stop()
localStream.getAudioTrack().stop()