7

Error: Failed to start MediaRecorder: Failed to execute 'getUserMedia' on "MediaDevices": getUserMedia is not supported.

Original: https://github.com/MKSx/Send-Audio-Plugin-BetterDiscord Error on line 1026.

UPD: getUserMedia() disabled in discord, alternative:https://github.com/l-Nuril-l/Voice-Messages-Plugin-BetterDiscord

UPD2: The alternative is dead

Code with problem:

navigator.mediaDevices.getUserMedia({audio: 'true'}).then(s => {
                plugin.media = new MediaRecorder(s);
                Logger.log("MediaRecorder started successfully");
            })
Nuril
  • 107
  • 2
  • 6
  • How are you installing and using this plugin? – Meera Datey Jul 10 '21 at 17:45
  • 1
    1) Need to install -> https://betterdiscord.app/ 2) Move js file here. Settings -> Plugins -> Open Plugins Folder. (or BetterDiscord\plugins). P.S. Also, for the plugin, you need to apply this commit so that the error from my question is displayed. https://github.com/MKSx/Send-Audio-Plugin-BetterDiscord/pull/16/commits – Nuril Jul 10 '21 at 18:10

1 Answers1

3

Intro

Basically, better discord is essentially an application running in something like a chrome browser. You can validate this by hitting CTRL+SHIFT+I.

The problem looks like a security issue in chrome related to accessing the microphone. I will also have a look in the following days, but the following solutions might work for you:

Update

I saw that you can potentially add flags to the discord app from the following link: https://www.reddit.com/r/discordapp/comments/91btrn/adding_electron_flags_to_discord_startup/

There a full list of potential command line switches @ https://peter.sh/experiments/chromium-command-line-switches/ .

You probably need to set the correct URL/domain after the parameter, e.g.

Discord.exe --unsafely-treat-insecure-origin-as-secure=
Menelaos
  • 23,508
  • 18
  • 90
  • 155
  • Thanks for the links! Im having the issue that in discord the only thing I can do is open the devtools. I also checked the permissions with `navigator.permissions.query({name: 'microphone'})` and permission was granted but still the same error as described above. – cwirz Jul 06 '21 at 11:34
  • 1
    My problem is not in Chrome, but all the solutions are only for it. – Nuril Jul 12 '21 at 19:02
  • I checked and found out that Betterdiscord is using Chrome 83. Tell me how to enable the flag using the console now: `chrome://flags/#unsafely-treat-insecure-origin-as-secure` With `window.location = "chrome://flags";` Failed to open the page with flags. Got an error: `Not allowed to load local resource: chrome://flags/` – Nuril Jul 13 '21 at 17:25
  • @Nuril btw, I wanted to ask what other software you have installed on your pc? e.g. node? Checking into how to open the location. – Menelaos Jul 13 '21 at 17:56
  • @Menelaos Yes I have node installed. – Nuril Jul 13 '21 at 18:04
  • @Νuril , can you try `Discord.exe --unsafely-treat-insecure-origin-as-secure` . I think you might need to add `=` with the URL of the domain website. – Menelaos Jul 13 '21 at 19:37
  • @Menelaos To begin with, I decided to try it in regular Chrome, this is what happened:[link](https://i.ibb.co/19yzw1c/image.png). The parameter is not enabled, and a notification appears that the parameter is not supported, but a link appears in the box. In Discord, the function still doesn't work. – Nuril Jul 13 '21 at 20:26
  • 1
    I've come to the conclusion that this flag is needed for sites using http or localhost, but Discord uses https and this solution doesn't work for me. Perhaps the Discord developers have deliberately disabled this feature? – Nuril Jul 14 '21 at 18:05
  • 2
    @Nuril I'm thinking of trying out this plugin as an extension directly in the chrome browser. But I havn't had the time and I think I will have to rewrite parts of it. I'm more suspecting that google chrome has increased the security restrictions so that a script can't start recording you. Seems also there were security issues with discord plugins which could also be a reason for them to tighten security. e.g. https://www.pocket-lint.com/apps/news/152340-discord-malware-is-stealing-users-passwords – Menelaos Jul 15 '21 at 09:39