0 votes

How to get/set AudioStreamPlayer current duration? im using mono (c#) version but you can answer using gdscript

in Engine by (20 points)

1 Answer

+1 vote
Best answer

So, you're looking for the length of the AudioStream that your AudioStreamPlayer is currently playing?

If so, in GDScript that'd be...


If, instead, you're looking for the time remaining in the currently playing stream, I guess you could get that with a combination of the above (the total duration) and this:

$AudioStreamPlayer.get_playback_position() which returns the current time into playing track.

by (10,936 points)
selected by

I want to skip first 39 seconds after first loop
I have a audio file which is 58 seconds so i want to do:
1st loop : 58 seconds
2nd loop: 58 minus 39 seconds
3rd looop: 58 minus 39 seconds

You mentioned only getters if there is no setters this is a shame

Well, you don't have to guess about what is and is not available. You can just check the docs. For AudioStreamPlayer, that's here:


There, you can see there's a seek function that'll allow you to set the position in the AudioStream.

Additionally, there's a finished signal you could use to tell when the stream finishes.

Those things, used together, should give you all the functionality necessary to do what you describe, I think.

Thanks for documentation i connected finished signal to function play :
void play ( float fromposition=0.0 )
Plays the audio from the given from
position, in seconds.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.