问题
I am trying to write some code that can play an .mp3 file. I thought I could use the mciSendString call, but I am getting a strange error.
So, when I have this code:
int rc=mciSendString(L"open songname.mp3 alias song1", NULL, 0, 0);
rc
returns with the number 266, and the error string returned with GetErrorString
was:
"Unknown problem while loading the specified device driver."
Error 266 is MCIERR_CANNOT_LOAD_DRIVER
I have also tried:
int rc=mciSendString(L"open songname.mp3 type mpegvideo alias song1", NULL, 0, 0);
and received the same error.
I thought it may be the mp3 file, but I tried a few different ones and kept getting the same error.
My code is in C++ and is running on Windows 7. Is my code missing something?
回答1:
Try surrounding songname.mp3
with an extra pair of quotes (be sure to escape them with backslashes).
回答2:
It looks like I didn't have an mp3 codec for MCI. (Actually answered by @LightnessRacesinOrbit in comments to the question.)
来源:https://stackoverflow.com/questions/12984851/playing-mp3-files-with-mcisendstring-mcierr-cannot-load-driver