Hello, I have done some research on playing .wav files in C++(As you can only play .wav files) and I've been having some trouble.
The coding below works, it just doesn't play the whole song. It plays around 10 seconds of it, then stops. Does anyone have any suggestions?

I am using windows XP, and Dev C++

And apologies for the grammatical error of "it's"

Thanks guys!

#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
PlaySound("888.wav", NULL, SND_FILENAME|SND_LOOP);
  return 0;
}

I'm not familiar with the function, but maybe try adding getchar(); right before the return statement? Or add a break there and see if it reaches the break before the song finishes playing. I would assume that the playsound command doesn't just cause the program to hang there until it's finished playing because that could cause problems.

I've tried using the getchar(); method, but I've had no luck. Could you please explain to me what a break is, and how I might go about implementing it?

I'm not sure how you do it in Dev C++ actually. In VS you just click the grey space beside the line you want to add a break on, and whenever the program reaches that point, it pauses it where it is, so you can view all of the values of the variables and such and go through your program line by line to see how it executes.

Ok, I might try the first method again just to check I'm doing it right...

You simply add the getchar(); before the return? What exactly does this achieve?

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.