From b6db09968dbae879a7d0c172eb22cbd2f307d012 Mon Sep 17 00:00:00 2001 From: Micky Date: Mon, 5 Sep 2022 22:08:12 +0200 Subject: [PATCH] Fix AudioStreamPlayer2D and 3D's `playing` not updating right away --- doc/classes/AudioStreamPlayer2D.xml | 4 ++-- doc/classes/AudioStreamPlayer3D.xml | 4 ++-- scene/2d/audio_stream_player_2d.cpp | 3 +++ scene/3d/audio_stream_player_3d.cpp | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml index ae86fd0e664..81755b580f9 100644 --- a/doc/classes/AudioStreamPlayer2D.xml +++ b/doc/classes/AudioStreamPlayer2D.xml @@ -29,7 +29,7 @@ - Plays the audio from the given position [param from_position], in seconds. + Queues the audio to play on the next physics frame, from the given position [param from_position], in seconds. @@ -73,7 +73,7 @@ The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate. - If [code]true[/code], audio is playing. + If [code]true[/code], audio is playing or is queued to be played (see [method play]). The [AudioStream] object to be played. diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 11d6e9cc7a6..f711210ca1c 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -29,7 +29,7 @@ - Plays the audio from the given position [param from_position], in seconds. + Queues the audio to play on the next physics frame, from the given position [param from_position], in seconds. @@ -94,7 +94,7 @@ The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate. - If [code]true[/code], audio is playing. + If [code]true[/code], audio is playing or is queued to be played (see [method play]). The [AudioStream] resource to be played. diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 9ac3083718d..2ded2091801 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -284,6 +284,9 @@ bool AudioStreamPlayer2D::is_playing() const { return true; } } + if (setplay.get() >= 0) { + return true; // play() has been called this frame, but no playback exists just yet. + } return false; } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index b9d95672fe5..75e840c24bb 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -606,6 +606,9 @@ bool AudioStreamPlayer3D::is_playing() const { return true; } } + if (setplay.get() >= 0) { + return true; // play() has been called this frame, but no playback exists just yet. + } return false; }