0 votes


I'm encountering a very strange bug concerning the web export.
I created a little audio visualization program which uses the microphone as audio input. The problem is when building the project and testing it on a local-host server it works as it should. But once I upload it to my little server in the basement and I open the program from there, I get an error when I start recording.

The error:

Uncaught TypeError: navigator.mediaDevices is undefined

Project build
For recording I simply use a AudioStreamPlayer with an AudioStreamMicrophone connected to a second bus which feeds back to the Master bus and has an SpectrumAnalyser effect.

The recording button has following code:

func _on_StartRecording_pressed():
    if recorder.playing:
        AudioServer.set_bus_mute(0, false)
        $UpperMenu/StartRecording.text = "Start Recording"
        AudioServer.set_bus_mute(0, true)
        $UpperMenu/StartRecording.text = "Stop Recording"

The working way (in ubuntu terminal):

douwe@Douwe-Laptop:~/Documents/Messing_with_code/godot_audiovisualizer/WebBuild$ python3 -m http.server

Serving HTTP on port 8000 ( ...

Then surfing to localhost:8000/ and everything works fine.

The not working way (also ubuntu terminal):
First zipping the folder in AudioVisualizer.zip

douwe@Douwe-Laptop:~/Documents/Messing_with_code/godot_audiovisualizer$ scp AudioVisualizer.zip douwe@douwco.com:~

douwe@Douwe-Laptop:~/Documents/Messing_with_code/godot_audiovisualizer$ ssh douwe@douwco.com

douwe@douwe-server:~$ unzip AudioVisualizer.zip 
Archive:  AudioVisualizer.zip
   creating: WebBuild/
  inflating: WebBuild/AudioVisualizer.html  
  inflating: WebBuild/AudioVisualizer.js  
  inflating: WebBuild/AudioVisualizer.pck  
  inflating: WebBuild/AudioVisualizer.png  
  inflating: WebBuild/AudioVisualizer.wasm  
 extracting: WebBuild/favicon.png 

douwe@douwe-server:~$ mv WebBuild/ AudioVisualizer

douwe@douwe-server:~$ sudo mv AudioVisualizer /var/www/html/

If I then go to www.douwco.com (domain to my little server) the site opens correctly until I press the record button which is when the error occurs.

If you have any suggestions towards finding a solution or know what is wrong, I will appreciate your help.

in Engine by (15 points)

1 Answer

+1 vote
Best answer

i think its a security issue with the browser. Most browser dont allow media support on unsecure http connections. You need to serve the files via https.
This restriction does not apply to localhost because localhost is allways trated as secure.

by (3,940 points)
selected by

Ahhh that makes sense. Thank you. I will look into it.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.