mixHasMusicDecoder function

bool mixHasMusicDecoder(
  1. String? name
)

Check if a music decoder is available by name.

This result can change between builds AND runs of the program, if external libraries that add functionality become available. You must successfully call Mix_OpenAudio() or Mix_OpenAudioDevice() before calling this function, as decoders are activated at device open time.

Decoder names are arbitrary but also obvious, so you have to know what you're looking for ahead of time, but usually it's the file extension in capital letters (some example names are "MOD", "MP3", "FLAC").

\param name the decoder name to query. \returns SDL_TRUE if a decoder by that name is available, SDL_FALSE otherwise.

\since This function is available since SDL_mixer 2.6.0

\sa Mix_GetNumMusicDecoders \sa Mix_GetMusicDecoder

extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name)

Implementation

bool mixHasMusicDecoder(String? name) {
  final mixHasMusicDecoderLookupFunction = libSdl2Mixer.lookupFunction<
      Int32 Function(Pointer<Utf8> name),
      int Function(Pointer<Utf8> name)>('Mix_HasMusicDecoder');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = mixHasMusicDecoderLookupFunction(namePointer) == 1;
  calloc.free(namePointer);
  return result;
}