Topic was automatically imported from the old Question2Answer platform.
Asked By
mrwappa
I am currently running Godot 3.2, using AudioStreamPlayer and VideoPlayer to play Audio and Video.
In the docs for Godot 3.1 there is a section for AudioStream where it describes a get_length() method that returns length of an audio stream in seconds.
Is there any similiar solution for AudioStreamPlayer and VideoPlayer in Godot 3.2 so that I can get the duration of those two media types?
An AudioStreamPlayer has an stream property, which is an AudioStream object. Using that object, you can access the AudioStream’s get_length() method.
Likewise, a VideoStreamPlayer has a stream property, which is a VideoStream object. It also has an underlying get_length() method which can be used to retrieve the stream’s length
So it seems you’re half right. AudioStream’s get_length() method does indeed exist. However, firstly, VideoStreamPlayer does not exist. VideoPlayer does exists though, and it has a VideoStream but no get_length() method attached.
Thanks, it’s good to have AudioStream’s get_length at the very least.
mrwappa | 2020-04-08 19:34
So, a couple of pieces of unintentional misinformation here…
Yeah, I meant VideoPlayer, not VideoStreamPlayer.
When I initially looked at the VideoStream object, it looked very underdocumented and I couldn’t tell if it had a get_length method or not. Just before posting that response, I looked again and saw a get_length method, so I updated the response. Obviously, that second look must have been back on my open AudioStream browser tab…