wiki.icculus.org
[ front page | index | search | recent changes | git repo | offline html ]
(This function is part of SDL_sound, a separate library from SDL.)

Sound_GetDuration

Retrieve total play time of sample, in milliseconds.

Header File

Defined in <SDL3_sound/SDL_sound.h>

Syntax

Sint32 Sound_GetDuration(Sound_Sample *sample);

Function Parameters

Sound_Sample * sample Sound_Sample from which to retrieve duration information.

Return Value

(Sint32) Returns Sample length in milliseconds, or -1 if duration can't be determined for any reason.

Remarks

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.

Thread Safety

It is safe to call this function from any thread.

Version

This function is available since SDL_sound 1.0.0.


CategoryAPI, CategoryAPIFunction, CategorySDLSound


[ edit | delete | history | feedback | raw ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.