webrtc: prevent NotReadableError when publishing with Android (#2698) (#2842)

This commit is contained in:
Alessandro Ros 2023-12-26 12:53:33 +01:00 committed by GitHub
parent e6fec31516
commit 1feeba92b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -717,13 +717,19 @@ const initialize = () => {
}
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(() => Promise.all([
populateDevices(),
populateCodecs(),
]))
.then(() => {
state = DEVICE;
render();
.then((stream) => {
return Promise.all([
populateDevices(),
populateCodecs(),
])
.then(() => {
// free the webcam to prevent 'NotReadableError' on Android
stream.getTracks()
.forEach(track => track.stop());
state = DEVICE;
render();
});
})
.catch((err) => {
state = ERROR;