What is difference between Autoplay and Playing of AudioStreamPlayer

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

The autoplay and playing setting has same effect at game starting, why they are separate?

:bust_in_silhouette: Reply From: Zylann

playing is whether it’s playing right now. It will play the sound in the editor, which is not necessarily wanted, especially if your sound is a loop.

autoplay plays from the start of the sound only in game, when the scene loads.

They may have the same result when testing the scene, but they do different things.


func _ready():

equals to enable Autoplay option?

suyen729 | 2020-04-12 13:47

In this case I would not expect this to work with autoplay when done in _ready, you’d be at the mercy of the order in which nodes execute. Using play is much clearer.

autoplay is better suited for cases you already chosen the stream in the editor and want it to play automatically without using a script.

Zylann | 2020-04-12 14:07

But why there is a bool var named autoplay in script, it’s is equal to enable playing in game, why not remove autoplay?

suyen729 | 2020-04-13 11:52

Because it has a use in the editor. If it was not there, you would be forced to add a script to play the sound. playing kind of does that too but as I said, it would then play the sound in the editor, which may not be wanted.

Zylann | 2020-04-13 17:28

So the bool var autoplay is not require in script?

suyen729 | 2020-04-14 09:51

autoplay does the same thing as calling play() in _ready() in the game, so it doesnt require a script.

Zylann | 2020-04-14 18:39