I am trying to get music to loop in the background of a game. However im really not sure how to do this. Can anyone give me a starting point please? I am using Visual C++ btw.

If you are on windows, then you can use PlaySound . If not then there might be something similar to your
OS. If all fails, you will have to use a 3rd party library.

I got this piece of code

#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

#pragma comment(lib,"Winmm.lib")

int main(void)
{
	PlaySound("file.wav",NULL,SND_FILENAME);

	return 0;
}

But it will only play at the begining of the program where i want it to loop- how can i do this?

I got it to work by using this code

PlaySound("beep.wav",NULL,SND_FILENAME|SND_ASYNC | SND_LOOP);

Thanks for your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.