godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.76k stars 21.13k forks source link

AudioStreamPlayer will play upon re-entering tree even if paused #49153

Open KoBeWi opened 3 years ago

KoBeWi commented 3 years ago

Godot version:

364ea7f / 3.3

Steps to reproduce:

  1. Add audio stream player (any)
  2. Make it autoplay
  3. Remove it from tree
  4. Pause
  5. Re-add it to tree
  6. It will play even though it should be paused

Minimal reproduction project:

AudioRepro.zip Space to toggle pause Z to remove player from tree for 1 second Try pausing while player is outside tree.

KoBeWi commented 2 years ago

Seems like this was fixed on master.

bumblemeow commented 1 year ago

A work-around I've been using is to set stream_paused = true, then immediately call play():

$IntroMusic.stream_paused = true $IntroMusic.play()

The stream will remain paused until the game is unpaused as the play() function respects the paused state.