Fix AudioStreamPlayer not resuming after returning to SceneTree
This commit is contained in:
parent
48cfa0da70
commit
a7ce7b1d3f
3 changed files with 17 additions and 2 deletions
|
@ -43,13 +43,18 @@ void AudioStreamPlayer2D::_notification(int p_what) {
|
||||||
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
|
set_stream_paused(false);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
stop();
|
set_stream_paused(true);
|
||||||
AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this);
|
AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_PREDELETE: {
|
||||||
|
stop();
|
||||||
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_PAUSED: {
|
case NOTIFICATION_PAUSED: {
|
||||||
if (!can_process()) {
|
if (!can_process()) {
|
||||||
// Node can't process so we start fading out to silence.
|
// Node can't process so we start fading out to silence.
|
||||||
|
|
|
@ -247,13 +247,18 @@ void AudioStreamPlayer3D::_notification(int p_what) {
|
||||||
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
|
set_stream_paused(false);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
stop();
|
set_stream_paused(true);
|
||||||
AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this);
|
AudioServer::get_singleton()->remove_listener_changed_callback(_listener_changed_cb, this);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_PREDELETE: {
|
||||||
|
stop();
|
||||||
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_PAUSED: {
|
case NOTIFICATION_PAUSED: {
|
||||||
if (!can_process()) {
|
if (!can_process()) {
|
||||||
// Node can't process so we start fading out to silence.
|
// Node can't process so we start fading out to silence.
|
||||||
|
|
|
@ -40,6 +40,7 @@ void AudioStreamPlayer::_notification(int p_what) {
|
||||||
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
|
set_stream_paused(false);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||||
|
@ -64,6 +65,10 @@ void AudioStreamPlayer::_notification(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
set_stream_paused(true);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_PREDELETE: {
|
||||||
for (Ref<AudioStreamPlayback> &playback : stream_playbacks) {
|
for (Ref<AudioStreamPlayback> &playback : stream_playbacks) {
|
||||||
AudioServer::get_singleton()->stop_playback_stream(playback);
|
AudioServer::get_singleton()->stop_playback_stream(playback);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue