1 Replies - 778 Views - Last Post: 02 June 2013 - 05:32 AM Rate Topic: -----

#1 thijmen321   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-June 13

problem - why does this code only play wave?

Posted 02 June 2013 - 04:16 AM

Quote

Why does this code only play .wav:

class MusicPlayer
    {
        [DllImport("winmm.dll")]

        private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);

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

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

        public void stop()
        {
            string command = "stop MP3";
            mciSendString(command, null, 0, 0);

            command = "close MP3";
            mciSendString(command, null, 0, 0);
        }
    }




Is This A Good Question/Topic? 0
  • +

Replies To: problem - why does this code only play wave?

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,231
  • Joined: 12-December 12

Re: problem - why does this code only play wave?

Posted 02 June 2013 - 05:32 AM

I would see if the following amendment to play() makes a difference.

string command = "play MP3 from 0";


There is also a plug-in at code-project you might consider.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1