Retrieve total play time of sample, in milliseconds.
Defined in <SDL3_sound/SDL_sound.h>
Sint32 Sound_GetDuration(Sound_Sample *sample);| Sound_Sample * | sample | Sound_Sample from which to retrieve duration information. |
(Sint32) Returns Sample length in milliseconds, or -1 if duration can't be determined for any reason.
Report total time length of sample, in milliseconds. This is a fast call. Duration is calculated during Sound_NewSample*, so this is just an accessor into otherwise opaque data.
Please note that not all formats can determine a total time, some can't be exact without fully decoding the data, and thus will estimate the duration. Many decoders will require the ability to seek in the data stream to calculate this, so even if we can tell you how long an .ogg file will be, the same data set may fail if it's, say, streamed over an HTTP connection. Plan accordingly.
Most people won't need this function to just decode and playback, but it can be useful for informational purposes in, say, a music player's UI.
It is safe to call this function from any thread.
This function is available since SDL_sound 1.0.0.