How to get the length of audio resource (*.ogg) in Godot 3??

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By earlroxas
:warning: Old Version Published before Godot 3 was released.

Well I need to get the length of audio resource (.ogg), I’ve searched the doc but well… no luck… class AudioStreamOGGVorbis, AudioStream dont have length variable. So, how do you get the length of Audio Resource in Godot 3?

:bust_in_silhouette: Reply From: literalcitrus

If you have set the AudioStream resource to a StreamPlayer (which I assume you will be doing if it’s being used as music), then you can use StreamPlayer.get_length() to get the length of the audio in seconds.

StreamPlayer? You mean the one with Godot 2.X? Sorry, In this question I use Godot 3 (Let me edit the question). Have you tried Godot 3 yet? If you have, please tell me how to get the Audio Length.

earlroxas | 2018-01-21 07:01

And I checked the Godot 3 doc, the AudioStreamPlayer class in Godot3 dont have get_length method.

earlroxas | 2018-01-21 07:05

:bust_in_silhouette: Reply From: uriel

it is not an AudioStreamPlayer but an AudioStream :wink: