How can I get AudioStreamPlayer to play sounds?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bepis

Hi, I’m trying to convert a game from Godot 2.1 to 3.4 and I’m having an issue with the audio. Godot 2.1 had a SamplePlayer class that I’m trying to re-create using AudioStreamPlayers but so far I can’t get any sounds to actually play.

I’m basically creating a stream player for each sound effect in a directory and creating a dictionary of all the sounds:

used_player = = load("res://assets/effects/%s" % file_name)
# store the player keyed by the name
effect_players[effect_name] = used_player

So later I can do something like this:

func play(name):
        print("Trying to play missing effect: %s" % name)

I’ve verified the loaded files are of class AudioStreamSample and printed the to verify they’re loaded but still nothing. Audio buses are all at default and all the files are .wav. Any ideas?

:bust_in_silhouette: Reply From: bepis

Nvm… Apparently you have to add the stream players to the scene to actually be able to use them.


1 Like