Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | wombatTurkey | |
Old Version | Published before Godot 3 was released. |
The reason I’m using this method is because the Sample Player doesn’t support .ogg
, nonetheless, this way should work but it’s not and I think I am messing up somewhere
Anyways, here is the code:
extends Node
var playlist = {"intro2": "MyTempStream"} # (This is just a fake, filler)
func play(name, loop):
if(playlist.has(name)):
yield(get_tree(), "idle_frame")
playlist[name].play()
print(playlist[name])
print(playlist[name].get_pos())
print("Playing: "+str(name))
return
var song = ResourceLoader.load("res://NXSBIN/img/rpg/Sounds/"+str(name)+".ogg")
var temp_stream = StreamPlayer.new()
temp_stream.set_name(name)
temp_stream.set_stream(song)
temp_stream.set_autoplay(true)
temp_stream.set_volume(0.50)
print(temp_stream.get_volume())
add_child(temp_stream)
if(loop):
temp_stream.set_loop(true)
playlist[name] = temp_stream;
So, everything works fine the first time I do play('filename')
, but when doing it again… it doesn’t play the attached StreamPlayer
, which is really odd because look:
Once I have that name added to my dict
I get:
Which it’s referencing correctly back to the stream player. I can actually call any of these functions here and it works. But for some odd reason, when I do .play()
I hear nothing. And what’s even more odd, if I spam this play("filename")
call for about 10 seconds straight over and over again, I can hear it play correctly, but only one time…
Is there some type of delay happening that I don’t know of? I’m very new to the gdscript as well so I’m probably screwing up somewhere