The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I am trying to load an audio file from my PC filesystem with FileDialog node and load the file by the load() method, but it returns a null, so how can I implement this?

func _on_FileDialog_file_selected(path):
   #The path /home/me/Music/Classic.mp3 = load(filePaht)
Godot version Gogot 3.5v
in Engine by (30 points)

You've passed in path but are referencing filePaht??

Oh sorry, but this is not the problem, I just typed it wrong.

func _on_FileDialog_file_selected(path):
#The path /home/me/Music/Classic.mp3 = load(path)

What error do you get?

The is no error, the load(path) method doesn't load the path and it returns null.

Are you sure there's nothing in either the dos console (if running in Windows) or the Output or Debugger windows in Godot? You can't normally just call "load" on any old file. And I don't think Godot can handle mp3s either.

yeah you're right there is an error in the Debugger window: E 0:00:19.073 _load: No loader found for resource: /path/to/file.mp3.

1 Answer

+3 votes
Best answer

Since you're trying to load a raw, filesystem-based file (as opposed to an imported resource), I think you'll have to work a little harder. Something like this should work (for example):

var path = "/path/to/some.mp3"
var, File.READ)
var stream = = snd_file.get_buffer(snd_file.get_len())
$ = stream
by (22,674 points)
selected by

Can Godot handle mp3s?

Yes, as demonstrated above...

Cool. I didn't know this node existed. All the google results for "godot mp3" say it's not supported (but they are quite old now).

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 Frequently asked questions and 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 [email protected] with your username.