I wonder if the issue is part of the AudioServer being separate from the main loop, so it doesn't get the function calls in the same order. Though the code you presented in the new project should work regardless... Hmm.
Out of curiosity, does replacing $test.stop()
with $test.stream_paused = true
work or at least pause the stream like expected? Also, have you tried using var test = get_node("test")
and test.play(); test.stop()
instead of $test
? Maybe the get_node calls through $
are contributing to the problem.
Though regardless, I would expect the above code to work. I'll try to do a quick test on one of my projects and see if I get the same results.
Edit : I just tested and I am getting the same results with Godot 3.2 on Windows. The code I'm using is the following, and it exhibits the same issue:
extends Control
func _ready():
var stream_player = get_node("AudioStreamPlayer");
stream_player.play();
stream_player.stop();
Though, the following did not, but the music plays for about a half-second before stopping:
extends Control
func _ready():
var stream_player = get_node("AudioStreamPlayer");
stream_player.play();
yield(get_tree(), "idle_frame")
stream_player.stop();
However, the expected functionality does not work, which makes think this might be a bug.