How to Loop Music In C++ (Simple)
Max O'Didily
How to Loop Music In C++ (Simple)
Greetings, today we are here with another C++ tutorial. This C++ tutorial will teach you how to loop music using the mmsystem.h and winmm.lib libraries. This will only work with .wav files and can only be used on a Windows OS.
We simply need to just use the PlaySound function. We pass in a file path of the wav file we wish to play. A NULL as we are using a file path to tell the PlaySound function where our wav music file is. We then pass in SND_FILENAME, SND_LOOP and SND_ASYNC. SND_FILENAME is used to tell the PlaySound function that we are using a file path to locate the wav file and SND_ASYNC means the thread will carry on executing code while the music is playing.
However, we also need to make sure our C++ program doesn't close, so we need to give it something to do. A simple way could be asking for user input.
Thanks for watching this tutorial on how to loop/repeat music using C++.
Here is a tutorial on how to play music using C++: https://www.youtube.com/watch?v=CrPHVvgENq0
Subscribe to keep notified when I upload: https://tinyurl.com/SubMaxODidily
How to Loop Music In C++ (Simple) ... https://www.youtube.com/watch?v=kLkiM5N32aY
10430189 Bytes