Fix AudioStreamPlayer2D and 3D's `playing` not updating right away

This commit is contained in:
Micky 2022-09-05 22:08:12 +02:00
parent e3a51e53ef
commit b6db09968d
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;
}