Thread: Problems loading mp3s with MCI

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    43

    Problems loading mp3s with MCI

    Hello long time no see guys

    Anyway im having trouble loading mp3 files with MCI

    Im doing this

    std::string szCommand = "open \"test.mp3\" type mpegvideo alias test";

    mciSendString(szCommand.c_str(), NULL, 0, 0)

    It keep returning 266 and it does not know what that error code it when I do the lookup mci error code check thing.

    I have absolutely no problems loading and playing wav files with almost identical code.

    I have MSVC2005 and vista ultimate 64 bit.

    Any clue whats wrong? I just want to play some mp3s without much hassle

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    std::string szCommand = "open \"test.mp3\" type mpegvideo alias test.mp3";
    http://www.google.com/search?q=MCI+mp3&btnI

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    43
    Yep thats basically the code I cant get to work, it sucks!

    Vista issue maybe? I just dont get it

    Anyone know any quick easy ways to play mp3s maybe using other methods like directx or something?

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    did you try it with the .mp3 at the end?

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    43
    Oh sorry, ya i just did try and it didnt work.

    From what i understand from how it works that part isnt actually part of the filename. Had to go to a few diff sites before thought i understood the mciSendString() message stuff

    This code works fine for playing waves and returns 0:


    std::string szCommand = "open \"hurtdog.wav\" type waveaudio alias test";

    allegro_message("%d", mciSendString(szCommand.c_str(), NULL, 0, 0));

    std::string szCommand2 = "play test from 0";
    mciSendString(szCommand2.c_str(), NULL, 0, 0);

    Weird or maybe not? I am very new to windows coding

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    so this code says "Unknown error edf"?

    Code:
    std::string szCommand = "open \"test.mp3\" type mpegvideo alias test.mp3";
    
    BOOL error = mciSendString(szCommand.c_str(), NULL, 0, 0);
    TCHAR buf[256];
    
    mciGetErrorString(error, buf, 256);
    MessageBox(NULL, error?buf:_T("Unknown error edf"), _T("Title"), MB_OK);
    Last edited by robwhit; 07-30-2007 at 05:06 PM. Reason: removing unused code

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    43
    "An unknown problem while loading the specified device driver"

    Dont use the exact same message box code stuff as you but thats the message I get back from mciGetErrorString()

  8. #8
    Registered User
    Join Date
    Jul 2007
    Posts
    43
    Does the gamedev site lie and it is not possible to play mp3s this way? Anyone know or done it this way before?

    Thanks

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    put this in MP3UsingMCI.cpp:
    Code:
    #include <cstdio>
    #include <cstdlib>
    #include "MCI.h"
    and link with winmm.lib

    I renamed MP3UsingMCI.cpp to MP3.cpp for short filenames.
    Code:
    g++ MP3.cpp -lwinmm
    run:
    Code:
    a test.mp3
    works for me

    but your error says that it's a device driver problem. Did you look in the device manager?
    Last edited by robwhit; 07-31-2007 at 10:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. loading
    By lilhawk2892 in forum C++ Programming
    Replies: 9
    Last Post: 09-03-2006, 08:31 PM
  3. need help with .md3 file loading
    By Shadow12345 in forum Game Programming
    Replies: 2
    Last Post: 12-06-2002, 04:06 PM
  4. Loading Screen
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 04-06-2002, 11:48 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM