Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Soaku | |
Old Version | Published before Godot 3 was released. |
I’m having hard time with StreamPlayer component. I’ve created one to play menu music with the audio set through the editor. I also created other component and tried to play music downloaded from my website. Here it does not works.
I’ve tried creating new AudioStreamOGGVorbis object, setting its path to the file and then assigning it to StreamPlayer:
var player = get_node("../StreamPlayer")
player.stop()
var stream = AudioStreamOGGVorbis.new()
stream.set_path("user://assets/"+todo[0][1])
#Also tried using set()
player.set_stream(stream)
player.play()
Then I get 3 errors:
Condition ’ err ’ is true, returned: err
Condition ’ p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6 ’ is true, returned: ERR_INVALID_PARAMETER
Condition ’ !is_inside_tree() ’ is true
I also tried changing path of previously used object, created in editor:
var player = get_node("../StreamPlayer")
player.stop()
var stream = player.get_stream()
stream.set_path("user://assets/"+todo[0][1])
#As previously said, I also tried using set()
player.set_stream(stream)
player.play()
Here, I get no errors, but it plays the previously set song. When I did print(player.get_stream().get_path())
between set_stream()
and play()
the path I set it to.
PS: the todo var is previously defined and is correct.
Please, help. I really don’t know why it does not work.