-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioStreamPlayer emits finished
signal inconsistently.
#56156
Comments
finished
signal inconsistently.finished
signal inconsistently.
finished
signal inconsistently.finished
signal inconsistently.
Hi @Calinou , if I could be directed to where to look, I might be able to fix this issue myself. Thank you. |
Ok. Thanks. @Calinou |
I understand absolutely nothing about audio stream processing. But after playing around with the debugger, and comparing the behavior when playing I noticed the following: When playing godot/scene/audio/audio_stream_player.cpp Lines 48 to 50 in e9e2aaf
But when playing godot/scene/audio/audio_stream_player.cpp Lines 61 to 63 in e9e2aaf
|
The emission of the |
Anyone looking at this issue? 😊 @ellenhp Since it could be related to your past work on the audio, would you have an idea of a possible cause? We'd love to know if there's at least a workaround 😉 |
Hi, if somebody else has this problem, try my trick. Yes, it's not ideal solution, but it's works: class_name AudioPlayer
extends AudioStreamPlayer
signal audio_finished
@onready var check_track_finished_timer := Timer.new()
func _ready() -> void:
add_child(check_track_finished_timer)
audio_finished.connect(_some_func)
func play_track() -> void:
...
_check_is_finished()
await audio_finished
...
func _some_func() -> void:
....
func _check_is_finished() -> void:
if not playing:
audio_finished.emit()
check_track_finished_timer.stop()
return
check_track_finished_timer.timeout.connect(_check_is_finished)
check_track_finished_timer.start(0.5) Just example. If you have any questions or comments, I will be happy to answer. |
Found this issue after engaging with pull request #87830. This bug is directly caused by setting an audio clip's "loop" property to "true". I am using v4.3.stable.official [77dcf97]. Hopefully that can help a fix be found. Can work around this by setting the loop property to false and looping manually. I wanted to await for the finished signal at the end of a looping audiostream before running some code. I ended up restructuring my code to function differently, but it'd be great if this issue could be fixed. The "finished" signal appears to still fire, you can connect a function to the signal and it'll receive it. But, using await doesn't work. The code will never continue. I noticed that AudioStreamPlayer now has "Parameters -> Looping" but I cannot figure out how to set this via code, it's not mentioned in the docs. I tried "audio_player.looping = true", "audio_player.looping.on = true", and "audio_player.set_parameter("looping",true)". But, all of these return errors. Information on how to utilize this feature would be appreciated. |
Godot version
Godot_v4.0-dev.20211004_linux.64
System information
5.4.0-91-generic #102-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
Issue description
Godot master branch emits
finished
signal inconsistently for different audio files.Audios
001001.mp3
,001001.ogg
does not emitfinished
while002030.mp3
does emit.Godot 3.4 behaves correctly. Meaning all files emit
finished
signal.Steps to reproduce
Load project https://github.com/abdlquadri/GodotAudioPlayerSignalDemo/tree/main/TestingAudioPlayerSignals in Godot_v4.
Expect to see
fini
printed in console after audio stops.This expected behavior is true for some files (
002030.mp3
) but not others (001001.mp3
,001001.ogg
)You can load https://github.com/abdlquadri/GodotAudioPlayerSignalDemo/tree/main/TestingAudioPlayerSignals_v3 in Godot_v3 to see that it works for Godot 3
Minimal reproduction project
https://github.com/abdlquadri/GodotAudioPlayerSignalDemo/tree/main/TestingAudioPlayerSignals
The text was updated successfully, but these errors were encountered: