3

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?

Community
  • 1
  • 1
patfam
  • 31
  • 2
  • Well, do you have a MP3 codec installed that MCI can use? – Lightness Races in Orbit Oct 20 '12 at 03:28
  • @LightnessRacesinOrbit I assumed that Windows comes with it preinstalled. Windows Media Player can play the mp3 files I am attempting to play. Is that a valid way to check, or is there something else I should do to check if it is installed. – patfam Oct 20 '12 at 04:10
  • Windows Media File does not use MCI for playback IIRC. _Assuming_ anything -- particularly about something that is not working -- seems an odd choice. – Lightness Races in Orbit Oct 20 '12 at 13:47
  • Try giving a full, absolute path. – Lightness Races in Orbit Oct 20 '12 at 13:49
  • @LightnessRacesinOrbit I tried the full and absolute path, and that didn't seem to help. But, I tested the same call with a wav file, and it worked. It seems that you are are correct about the mp3 codec not being installed. Thanks. Do you know of a mci mp3 codec that I can install? – patfam Oct 21 '12 at 22:21
  • Sorry I don't remember the solution, though I hope it makes you feel a little better when I say I vaguely recall having struggled with exactly the same thing in the past. – Lightness Races in Orbit Oct 21 '12 at 23:29
  • As an aside, consider using an actual media library like [BASS](http://www.un4seen.com/). MCI is designed for little sound effects. – Lightness Races in Orbit Oct 21 '12 at 23:31

2 Answers2

0

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

ECrownofFire
  • 472
  • 4
  • 11
  • Good thought, but when I changed the call with the quotes, I still got the same 266 error. Sadly didn't fix the problem. – patfam Oct 20 '12 at 04:24
0

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

patfam
  • 31
  • 2