0 votes

Hi,
For a game, I need to play multiple sounds and musics. But I don't know why, it doesn't play the music, I tried with different wav files changing the settings in the node inspector, but it doesn't work neither in normal player, nor in the 3D player.
Someone can tell my how I can fix this error?
Thanks in advanced.

Godot version 3.2.3
in Engine by (353 points)

AudioStreamPlayer or AudioStreamPlayer2D?
Please give more info. how does your tree look, where and how do you call play?

I tried it in AudioStreamPlayer and in AudioStreamPlayer3D, but in two cases it doesn't work.

Is your stream empty?
Can you play the sound(.wav) file in the editor?
double click the sound file in the [file system] and it should open in the [inspector].
There's a [play] and [stop] button, a [spectrogram] and [duration] on the bottom of the inspector. See if you can play the sound file.
Sometimes .wav files exported from Audacity 2.1.0 doesn't export properly.

Aside from the above, can you give us exactly why you are using the sound. For example, walking sound etc. Because there is a case where your audio stream player constantly play to the point of you're not hearing it

1 Answer

+1 vote
Best answer

PaAu is a AudioStreamPlayer

PaAu.stream = loadfile(Url the music)

func loadfile(filepath):
    file.open(filepath, File.READ)
    var bytes = file.get_buffer(file.get_len())
    if filepath.ends_with(".mp3"):
        var newstream = AudioStreamMP3.new()
        newstream.loop = false
        newstream.data = bytes
        return newstream
    else:
        print ("ERROR: Wrong filetype or format")
    file.close()

just call PaAu.play()

by (211 points)
selected by
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.