Media Player Application using Windows Media Player in C#
Submitted by donbermoy on Friday, November 20, 2015 - 19:51.
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".
Right click the project to add reference.
And then on the COM tab, choose Windows Media Player.
Then click the windows media player in the toolbox and put it inside the form.
3. Now, have this code below inside the button1 as your browsing of files button.
In the Play button, have also this code:
And in the Stop button, copy this code:
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
- private void button1_Click(object sender, EventArgs e)
- {
- //get the filename of the choosen file
- if (opf.ShowDialog() == DialogResult.OK)
- {
- //display the filename on the textbox
- textBox1.Text = opf.FileName;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //get the filename and will be equal to the URL of the media player
- axWindowsMediaPlayer1.URL = textBox1.Text;
- //play the file
- axWindowsMediaPlayer1.Ctlcontrols.play();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- //stop the file
- axWindowsMediaPlayer1.Ctlcontrols.stop();
- }
Comments
Add new comment
- Add new comment
- 1408 views