Create Mp3 Music Player in C#.NET


Mp3 Player Project in C#.NET

In this article let me explain how to create Mp3 player play audio file in C#.Net. We can create in many different ways but in this articles i'm going to show you easiest way to create mp3 player by using Microsoft given Window Media Component. So now let start from begining Open Visual Studio, I'm using Visual Studio 2012

Follow this Step to Create MP3 Player :

  1. Open Visual Studio
    • Choose Files File New Project
    • Choose Template Visual C# Windows Form Application
  2. Add Windows Media Player Components to Toolbar
    Now we need to Add Windows Media Player Component in our Toolbar for that just follow this steps :
    • Right Click on Toolbar Open Space
    • Click on Choose Items
    • Now Click COM Components Search for Windows Meida Player Checked the Checkbox Click Ok
    • Before Continue Please Check that Windows Media Player Added in your Toolbar or not

Design Windows Application Forms

Design your Media Player as you like otherwise you just design how i done by using above image

Steps to Design

  • Drag and Drop openFileDialog1 from Toolbar
  • Drag and Drop Windows Media Player Control from Toolbar
  • Add 3 Button Controls as i shown in image
    • Button 1
      • Change Property for Button 1:
      • Text : Choose Mp3 Files
      • (Name) : btn_choosemp3files
    • Button 2
      • Change Property for Button 2:
      • Text : Reset
      • (Name) : btn_Reset
    • Button 3
      • Change Property for Button 3:
      • Text : Delete
      • (Name) : btn_Delete
  • Add one ListBox Change ListBox name in property : listBoxMp3file

C# Coding : Choose Mp3 Files Button Click

string[] Mp3files, Mp3path;        
        private void btn_choosemp3files_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Mp3files = openFileDialog1.SafeFileNames;
                Mp3path = openFileDialog1.FileNames;
                for (int i = 0; i < Mp3files.Length;i++)
                {
                    listBoxMp3Files.Items.Add(Mp3files[i]);                    
                }
            }
        }

C# Coding : Reset Button Click

        private void btn_Reset_Click(object sender, EventArgs e)
        {
            listBoxMp3Files.Items.Clear();
        }

C# Coding : Delete Button Click

private void btn_Delete_Click(object sender, EventArgs e)
        {
            listBoxMp3Files.Items.Remove(listBoxMp3Files.Items[listBoxMp3Files.SelectedIndex]);
        }

C# Coding : Double Click on Selected Item in ListBox

private void listBoxMp3Files_DoubleClick(object sender, EventArgs e)
        {
            WMP.URL = Mp3path[listBoxMp3Files.SelectedIndex];
        }

Download Mp3 Player Project with Source Code


Tag : C#, C# Project
0 Komentar untuk "Create Mp3 Music Player in C#.NET"

Back To Top