diff options
author | Micky <micheledevita2@gmail.com> | 2022-09-05 16:37:15 +0200 |
---|---|---|
committer | Micky <micheledevita2@gmail.com> | 2022-09-05 16:52:46 +0200 |
commit | a7ce7b1d3fdda49d6616dfff0bfdebeeb66170e4 (patch) | |
tree | 9dab2c3197a0f3f410359f92ff089f0e5c75838a | |
parent | 48cfa0da70022189e6e8499f0bde785547726e04 (diff) |
Fix AudioStreamPlayer not resuming after returning to SceneTree
-rw-r--r-- | scene/2d/audio_stream_player_2d.cpp | 7 | ||||
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 7 | ||||
-rw-r--r-- | scene/audio/audio_stream_player.cpp | 5 |
3 files changed, 17 insertions, 2 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index fc019b6cf9..85ec745aee 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -43,13 +43,18 @@ void AudioStreamPlayer2D::_notification(int p_what) { if (autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); } + set_stream_paused(false); } break; case NOTIFICATION_EXIT_TREE: { - stop(); + set_stream_paused(true); AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this); } break; + case NOTIFICATION_PREDELETE: { + stop(); + } break; + case NOTIFICATION_PAUSED: { if (!can_process()) { // Node can't process so we start fading out to silence. diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 0e7b71f74a..21cf3bdb3b 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -247,13 +247,18 @@ void AudioStreamPlayer3D::_notification(int p_what) { if (autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); } + set_stream_paused(false); } break; case NOTIFICATION_EXIT_TREE: { - stop(); + set_stream_paused(true); AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this); } break; + case NOTIFICATION_PREDELETE: { + stop(); + } break; + case NOTIFICATION_PAUSED: { if (!can_process()) { // Node can't process so we start fading out to silence. diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 04feb0dc6f..03115e765f 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -40,6 +40,7 @@ void AudioStreamPlayer::_notification(int p_what) { if (autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); } + set_stream_paused(false); } break; case NOTIFICATION_INTERNAL_PROCESS: { @@ -64,6 +65,10 @@ void AudioStreamPlayer::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { + set_stream_paused(true); + } break; + + case NOTIFICATION_PREDELETE: { for (Ref<AudioStreamPlayback> &playback : stream_playbacks) { AudioServer::get_singleton()->stop_playback_stream(playback); } |