mixGetAudioDuration function mixer
Get the length of a MIX_Audio's playback in sample frames.
This information is also available via the MIX_PROP_METADATA_DURATION_FRAMES_NUMBER property, but it's common enough to provide a simple accessor function.
This reports the length of the data in sample frames, so sample-perfect mixing can be possible. Sample frames are only meaningful as a measure of time if the sample rate (frequency) is also known. To convert from sample frames to milliseconds, use MIX_AudioFramesToMS().
Not all audio file formats can report the complete length of the data they will produce through decoding: some can't calculate it, some might produce infinite audio.
Also, some file formats can only report duration as a unit of time, which means SDL_mixer might have to estimate sample frames from that information. With less precision, the reported duration might be off by a few sample frames in either direction.
This will return a value >= 0 if a duration is known. It might also return MIX_DURATION_UNKNOWN or MIX_DURATION_INFINITE.
\param audio the audio to query. \returns the length of the audio in sample frames, or MIX_DURATION_UNKNOWN or MIX_DURATION_INFINITE.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL_mixer 3.0.0.
extern SDL_DECLSPEC Sint64 SDLCALL MIX_GetAudioDuration(MIX_Audio *audio)
Implementation
int mixGetAudioDuration(Pointer<MixAudio> audio) {
final mixGetAudioDurationLookupFunction = _libMixer
.lookupFunction<
Int64 Function(Pointer<MixAudio> audio),
int Function(Pointer<MixAudio> audio)
>('MIX_GetAudioDuration');
return mixGetAudioDurationLookupFunction(audio);
}