Playing mp3 files with mciSendString (MCIERR_CANNOT_LOAD_DRIVER)

2.1k views Asked by At

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?

2

There are 2 answers

1
ECrownofFire On

Try surrounding songname.mp3 with an extra pair of quotes (be sure to escape them with backslashes).

0
patfam On

It looks like I didn't have an mp3 codec for MCI. (Actually answered by @LightnessRacesinOrbit in comments to the question.)