Merge pull request #65378 from Mickeon/fix-audio-stream-2d-non-immediate-playing

Fix AudioStreamPlayer2D and 3D's `playing` not updating right away
This commit is contained in:
Rémi Verschelde 2022-11-22 21:29:56 +01:00
commit 95a4906bb4
No known key found for this signature in database
GPG key ID: C3336907360768E1
4 changed files with 10 additions and 4 deletions

View file

@ -29,7 +29,7 @@
<return type="void" />
<param index="0" name="from_position" type="float" default="0.0" />
<description>
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.
</description>
</method>
<method name="seek">
@ -73,7 +73,7 @@
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
</member>
<member name="playing" type="bool" setter="_set_playing" getter="is_playing" default="false">
If [code]true[/code], audio is playing.
If [code]true[/code], audio is playing or is queued to be played (see [method play]).
</member>
<member name="stream" type="AudioStream" setter="set_stream" getter="get_stream">
The [AudioStream] object to be played.

View file

@ -29,7 +29,7 @@
<return type="void" />
<param index="0" name="from_position" type="float" default="0.0" />
<description>
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.
</description>
</method>
<method name="seek">
@ -94,7 +94,7 @@
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
</member>
<member name="playing" type="bool" setter="_set_playing" getter="is_playing" default="false">
If [code]true[/code], audio is playing.
If [code]true[/code], audio is playing or is queued to be played (see [method play]).
</member>
<member name="stream" type="AudioStream" setter="set_stream" getter="get_stream">
The [AudioStream] resource to be played.

View file

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

View file

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