MIX_SetTrackLoops(3)

πŸ“¦
version 3.2.4 Β· 2 versions
, in fedora 44

✨ MIX_SetTrackLoops ✨

okay bestie, we're in the SDL_mixer3 functions era, and today's main character is MIX_SetTrackLoops(3) β€” the glow-up-your-loop-count function πŸ’…


🌸 NAME 🌸

MIX_SetTrackLoops β€” change the number of times a currently-playing track will loop. that's it, that's the whole job πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3_mixer/SDL_mixer.h>

bool MIX_SetTrackLoops(MIX_Track *track, int num_loops);

πŸ’– DESCRIPTION πŸ’–

so basically, this replaces any previously-set remaining loops. like, out with the old, in with the new, no negotiating 🫢

  • a value of 1 will loop to the start of playback one time
  • 0 will not loop at all, periodt
  • -1 requests infinite loops β€” infinite. forever. iconic πŸ‘‘
⚠️ real talk though: if the input is not seekable and num_loops isn't zero, this function will report success but the track will stop at the point it should loop. it's giving "yes ma'am" but not actually doing it 😭

the new loop count replaces any previous state, even if the track has already looped. no takebacks, no history, just vibes forward ✨

also this has no effect on a track that is stopped. or rather β€” starting a stopped track later will set a new loop count, replacing this value. stopped tracks can specify a loop count while starting via MIX_PROP_PLAY_LOOPS_NUMBER. so this function here? it's the mid-playback plot twist β€” it's intended to alter that count while the track is already out here living its life 🎧


🌈 FUNCTION PARAMETERS 🌈

  • track β€” the track to configure. the one you're obsessed with πŸ’œ
  • num_loops β€” new number of times to loop. Zero to disable looping, -1 to loop infinitely. simple as 🩷

⭐ RETURN VALUE ⭐

Returns true on success, false on error; call SDL_GetError() for details. slay if it works, go check the error if it doesn't πŸ™ˆ


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. multitask, bestie, it's what you do πŸ’«


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL_mixer 3.0.0. a certified classic, no cap πŸ”₯


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie!! πŸ’–βœ¨ this one's from the SDL_mixer source, version SDL_mixer 3.2.4, and yes it lives right there in the same manual page family as MIX_SetTrackLoops(3) β€” go forth and loop responsibly πŸ¦‹πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from