C # 4.0 Problems playing back .mp3 files at 192 kbps using winmm.dll

MCIERR_INTERNALI trying to create a simple media player inside the application, but I noticed that my code does NOT play music if the file does not have a low transfer rate of about 192 kbps or less. The problem is that most of my music is around 260-320 kbps.

Here is my code, if there is something that I can do for the "available" bitrate options, let me know, otherwise I will need a new DLL suggestion, please!

class MusicPlayer
{
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);

    private static void checkMCIResult(long code)
    {
        int err = (int)(code & 0xffffffff);
        if (err != 0)
        {
            throw new Exception(string.Format("MCI error {0}", err));
        }
    }

    public void open(string file)
    {
        string command = "open \"" + file + "\" type MPEGVideo alias MyMp3";
        checkMCIResult(mciSendString(command, null, 0, 0));
    }

    public void play()
    {
        string command = "play MyMp3";
        mciSendString(command, null, 0, 0);
    }
    public void pause()
    {
        string command = "stop MyMp3";
        mciSendString(command, null, 0, 0);
    }
}

** EDIT: -Winform application

-using Windows 7 sp1

-Using version of Visulal Studio 2013

-When errors fail, I now see error number 289, -256 = 22: MCIERR_INTERNAL, not sure what this is all about

+4
3

Windows, , , . :

  • MP3. 320 /. , , DRM, .
  • , STA, Winforms WPF. , , .
  • ACM. , " " . HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32, ACM.
  • , : , mciSendString(). , , .

:

    private static void checkMCIResult(long code) {
        int err = (int)(code & 0xffffffff);
        if (err != 0) {
            throw new Exception(string.Format("MCI error {0}", err));
        }
    }

:

    public static void open(string file) {
        string command = "open \"" + file + "\" type MPEGVideo alias MyMp3";
        checkMCIResult(mciSendString(command, null, 0, 0));
    }

MCI, MMSystem.h "" Windows SDK . C:\Program Files (x86)\Microsoft SDK\Windows\v7.1A\Include\MMSystem.h. MCIERR_INVALID_DEVICE_ID, 256 . Windows VS .

+6

, ( @Hans Passant), , , 277. , MCI mp3, ID3 (v2.x) tag - Album art, ..

, 2 , , ID3 ( ). -

0

Windows API, MP3, . / MP3 [?, 16KB ] , , . .

DirectShow ( # DirectShow.NET), Windows, MP3, : Windows Media ASF.

. :

, Microsoft MPEG-1, Windows.

0

All Articles