Media Player Application using Windows Media Player in C#

In this tutorial, I will teach you how to create a program that will open, play, and stop a windows media player application in C#. So, now let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application. 2. Add three buttons in your Form such as Choose File, Play, and Stop button; add also one textbox for the filename. Then right click anywhere on the toolbox and click "Choose Items". design Right click the project to add reference. design And then on the COM tab, choose Windows Media Player. design Then click the windows media player in the toolbox and put it inside the form. design 3. Now, have this code below inside the button1 as your browsing of files button.
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             //get the filename of the choosen file
  4.             OpenFileDialog opf = new OpenFileDialog();
  5.             if (opf.ShowDialog() == DialogResult.OK)
  6.             {
  7.                 //display the filename on the textbox
  8.                 textBox1.Text = opf.FileName;
  9.             }
  10.         }
In the Play button, have also this code:
  1.         private void button2_Click(object sender, EventArgs e)
  2.         {
  3.             //get the filename and will be equal to the URL of the media player
  4.             axWindowsMediaPlayer1.URL = textBox1.Text;
  5.             //play the file
  6.             axWindowsMediaPlayer1.Ctlcontrols.play();
  7.  
  8.         }
And in the Stop button, copy this code:
  1.         private void button3_Click(object sender, EventArgs e)
  2.         {
  3.             //stop the file
  4.             axWindowsMediaPlayer1.Ctlcontrols.stop();
  5.         }
Output: output For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer If you have some queries, feel free to contact the number or e-mail below. Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Comments

Add new comment