mciSendString won't play an audio file if path is too long

Viewed 2113

When the path+filename of a file is really long, I've noticed that

PlaySound(fName.c_str(), NULL, SND_ASYNC);

works, but not

mciSendString((L"open \"" + fName + L"\" type waveaudio alias sample").c_str(), NULL, 0, NULL);
mciSendString(L"play sample", NULL, 0, NULL);

Example of failing command:

open "C:\qisdjqldlkjsqdjqdqjslkdjqlksjlkdjqsldjlqjsdjqdksq\dajdjqjdlqjdlkjazejoizajoijoifjoifjdsfjsfszjfoijdsjfoijdsoifoidsjfojdsofjdsoijfoisjfoijoisdjfosjfqsd\Windows Critical Stop.wav" type waveaudio alias sample

But:

  • I really need mciSendString instead of PlaySound(), because PlaySound() doesn't play certain files (48 khz audio files, sometimes 24-bit files, etc.)

  • I need to be able to play audio files with potentially long paths because the end user of my app might have such files

How to make mciSendString accept long filenames?


Notes:

  • I've also tried with this MSDN example using mciSendCommand, but it's the same.

  • The max path+filename length is 127 (127: working, 128+: not working)

  • If really it's impossible to make mci* functions work with longer-than-127-char filenames, what could I use instead, just with winapi (without external libraries)? (PlaySound is not an option because doesn't work realiably with all the wav files, such as 48 khz: non-working, etc.)

3 Answers
Related