problem with devices in http...oh well

This commit is contained in:
Arjun Patel
2022-01-16 12:30:20 -08:00
parent 39aa1dfa9b
commit aabc6cc2e2
2 changed files with 39 additions and 28 deletions
+21 -15
View File
@@ -153,22 +153,28 @@ export default function AudioContextProvider({ children }) {
// first load just force check if permissions enabled
// through fake stream
useEffect(() => {
navigator.mediaDevices
.getUserMedia({ audio: { deviceId: audioInputDeviceId } })
.then((stream) => {
// stop playing anything
stopBothVideoAndAudio(stream);
try {
// won't work in https!!!
navigator.mediaDevices
.getUserMedia({ audio: { deviceId: audioInputDeviceId } })
.then((stream) => {
// stop playing anything
stopBothVideoAndAudio(stream);
console.log("Permission Granted");
setHasRecPermit(true);
})
.catch((e) => {
console.log("Permission Denied");
toast.error(
"Please make sure that you have connected a microphone and given permissions."
);
setHasRecPermit(false);
});
console.log("Permission Granted");
setHasRecPermit(true);
})
.catch((e) => {
console.log("Permission Denied");
toast.error(
"Please make sure that you have connected a microphone and given permissions."
);
setHasRecPermit(false);
});
} catch (error) {
console.log(error);
toast.error("something went wrong");
}
}, []);
// set recording device