• We just launched and are currently in beta. Join us as we build and grow the community.

Media Player Application using Windows Media Player in C#

Bitch

Steganography Expert
Divine
B Rep
0
0
0
Rep
0
B Vouches
0
0
0
Vouches
0
Posts
162
Likes
85
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 400 XP
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".

choose_items.png


Right click the project to add reference.

ttsreference_0.png


And then on the COM tab, choose Windows Media Player.

com.jpg


Then click the windows media player in the toolbox and put it inside the form.

winplayer.jpg


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. }

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.jpg


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

 

442,401

317,942

317,951

Top