Fix AudioStreamPlayer not resuming after returning to SceneTree

This commit is contained in:
Micky 2022-09-05 16:37:15 +02:00
parent 48cfa0da70
commit a7ce7b1d3f
3 changed files with 17 additions and 2 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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);
}