#I can't get the audio permission with navigator.mediaDevices pls help

15 messages · Page 1 of 1 (latest)

frank swan
#

hello, my code :

async function getAudioPermission() {
    // Demande d'accès à la caméra et au microphone
    await navigator.mediaDevices
      .getUserMedia({
        audio: true,
      })
      .then((stream) => {
        console.log("Got MediaStream:", stream);
        setMediaStream(stream);
      })
      .catch((err) => {
        console.error("Error accessing media devices.", err);
      });
  }
  useEffect(() => {
    getAudioPermission();
  }, []);

return (
      <button onClick={async () => await getAudioPermission()}>
        Get User Media
      </button>
)

audio.tsx:35 Error accessing media devices. DOMException: Permission denied

fierce quarryBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

frank swan
#

It seems browser-specific. When I load my app in Safari, it asks for permission, unlike in the Arc browser.

#

wtf

frank swan
#

async function checkAndRequestAudioPermission() {
// console.log(navigator.permissions);
// console.log(navigator.mediaDevices);
// console.log(navigator.mediaSession);

// donne les contraintes disponibles de l'appareil
// on poeut utiliser ces contrtaintes pour optimiser l'audio en donnant des valeurs plus opti que lappareil par default
// const getSupportedConstraints =
//   await navigator.mediaDevices.getSupportedConstraints();

// partage l'audio et la video de luser
// const getDisplayMedia = await navigator.mediaDevices.getDisplayMedia({
//   audio: true,
// });
// console.log(getDisplayMedia);

// donne le stream audio de l'user
const aa = await navigator.mediaDevices.getUserMedia({ audio: true });

console.log(aa);

// await navigator;

}

nothing happenned on arc browser

#

navigator.mediaDevices.getUserMedia({ audio : true })

small river
# frank swan async function checkAndRequestAudioPermission() { // console.log(navigator.p...
MDN Web Docs

After you've created the peer, you'll want to get the browser's permission to access the microphone. We'll be using the getUserMedia() method on the navigator.mediaDevices object.
The getUserMedia() endpoint takes a constraints object that specifies which permissions are needed. getUserMedia() is a promise which, when successfully resolved, re...

frank swan
#

mmm ok

#

thanks you

small river
#

this is what i found

#

there is also the browser compatibility issue

frank swan
#

thanks you

frank swan