I'm currently working on a project and I need to play a sound file (which is actually a video but I only want to play the sound). Someone told me I could use a PlaySound function but it's currently not working (it plays this sound when I run instead of the file I wanted https://dl.dropboxusercontent.com/u/45453297/Windows%20Background.wav)
int _tmain(int argc, _TCHAR* argv[])
{
PlaySound(TEXT("C:\\Users\\Ricardo\\Documents\\Visual Studio 2013\\Projects\\SomEVideo\\SomEVideo\\KinectAudio-02-23-32.wav"), NULL, SND_FILENAME);
return 0;
}
On stdafx.h I included these headers:
#include "windows.h"
#include "mmsystem.h"
I also linked winmm.lib on my project so I don't get no unresolved problems.
Thanks.
EDIT:
After been told that the path was wrong, I changed the file name to "t.wav" and placed it in the hard drive root to avoid typing errors. I also tried PlaySounDW and play it like a resource. Here's what I'v got so Far with no success:
int _tmain(int argc, _TCHAR* argv[])
{
PlaySoundW(TEXT("C:/t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySoundW(TEXT("C:\\t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySoundW(TEXT("t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySound(TEXT("C:/t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySound(TEXT("C:\\t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySound(TEXT("t.wav"), NULL, SND_FILENAME); //GetLastError returns 0
PlaySoundW(MAKEINTRESOURCE("C:/t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
PlaySoundW(MAKEINTRESOURCE("C:\\t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
PlaySoundW(MAKEINTRESOURCE("t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
PlaySound(MAKEINTRESOURCE("C:/t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
PlaySound(MAKEINTRESOURCE("C:\\t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
PlaySound(MAKEINTRESOURCE("t.wav"), GetModuleHandle(NULL), SND_RESOURCE); //GetLastError returns 1813
return 0;
}