This is a discussion on Play MP3 file using C# within the C# Programming forums, part of the Software Development category; Play MP3 files using C#. Goals: This project is used to play the mp3 files using c#. Steps: 1) Create ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Play MP3 files using C#. Goals: This project is used to play the mp3 files using c#. Steps: 1) Create a c# windows application. 2) create two textboxes and two button controls. 3) copy the following code. private string PlayCommand; private bool isOpen; [DllImport("winmm.dll")] private static extern long mciSendString( string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr oCallback); private void btnselectfile_Click(object sender, EventArgs e) { this.openFileDialog1.Filter = "MP3(*.mp3)|*.mp3| Widows File (*.wmv)|*.wmv"; if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { txtmediafile.Text = this.openFileDialog1.FileName.ToString(); OpenMediaFile(txtmediafile.Text.ToString()); //File string strFilePro = openFileDialog1.FileName; FileInfo oFileInfo = new FileInfo(strFilePro); //Find file size txtfilesize.Text = oFileInfo.Length.ToString(); //File Created date DateTime dtCreationTime = oFileInfo.CreationTime; txtfilecrdate.Text = dtCreationTime.ToString(); } } public void ClosePlayer() { PlayCommand = "Close MediaFile"; mciSendString(PlayCommand, null, 0, IntPtr.Zero); isOpen = false; } public void OpenMediaFile(string strFileName) { PlayCommand = "Open \"" + strFileName + "\" alias MediaFile"; mciSendString(PlayCommand, null, 0, IntPtr.Zero); isOpen = true; } public void PlayMediaFile(bool loop) { if (isOpen) { PlayCommand = "Play MediaFile"; if (loop) PlayCommand += " REPEAT"; mciSendString(PlayCommand, null, 0, IntPtr.Zero); } } private void btnclose_Click(object sender, EventArgs e) { ClosePlayer(); } private void btnplaysong_Click(object sender, EventArgs e) { PlayMediaFile(isOpen); } 4) run the application. |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-programming/2271-play-mp3-file-using-c.html | |||
| Posted By | For | Type | Date |
| Play MP3 file using C# | Web Hosting | This thread | Refback | 12-17-2007 12:50 PM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Which kind of games do you prefer to play? | arjkhanna | Game Development | 14 | 08-15-2008 10:07 PM |
| play mp3 file using java application? | saravanan | Java Programming | 1 | 03-26-2008 02:15 AM |
| Trouble getting movieclips to play at random | aramesh | Flash Actionscript Programming | 5 | 02-19-2008 06:48 AM |
| Can I play a sound onMouseOver? | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 09-13-2007 04:12 AM |
| How to play multiple .flv files using the RTMP connection. | oxygen | Flash Actionscript Programming | 1 | 07-24-2007 05:28 AM |