Project for Playing Audio and Video Files using Windows Media Player

Posted by in C# category on for Beginner level | Points: 250 | Views : 14301 red flag

Hello Friends,

In this article we will learn how we can play audio and video files in windows Application.


Hello Friends,

Today while pondering over with my friend on how we can play and video files.So, this is what we will be doing today in this article.


  1. Adding Windows Media Player Component
  2. Playing Video files in Windows Media Player

Using the code

  1. Create a New Windows Project in Visual Studio 2010.
  2. Go to tool box and Right Click on the Empty Space and select Choose Items and then to go to Com Tab and select Windows Media Player and click OK (Check Screen 1)
  3. Once we complete this step we will check get the Windows Media Player Control just drag and drop the control on the Windows Form.(Check Screen 2)
  4. Now drag and drop the Windows Media Player control that we have got,one button and one Open File Dialog on the form.The UI Will be as Screen Number 3

Screen 1 :- Adding Windows Media Player Component

Screen 2 :- Windows Media Player

Screen 3 : UI


  1. Once we click the browse button a file dialog box will be opened and tell us to choose the files to play
  2. The file type supported are mp3,wav,mp4,mov,wmv,mpg
  3. Once we select the files from the above extension and click ok the video will start playing
  4. While the video playing you can right click on the control and get more options for video setting.

Screen 4: Output

// Code behind
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

        private void Browse_Click(object sender, EventArgs e)
            ofddialog.Filter = "(mp3,wav,mp4,mov,wmv,mpg)|*.mp3;*.wav;*.mp4;*.mov;*.wmv;*.mpg|all files|*.*";

                // axWindowsMediaPlayer1 is the object of the Windows Media Player class that allows to get the path 
                // to play the file in windows media player component
                axWindowsMediaPlayer1.URL = ofddialog.FileName;
            label2.Text = ofddialog.FileName;

Note := 

We have used axWindowsMediaPlayer1 object of the Windows Media Player class that allows to get the path to play the file in windows media player component with its URL Method.


For support of file types in Windows Media Player you can check

Note :- The windows media Player dll is available with all Windows Operating System except With Windows 8 Enterprise N Edition.To get Windows Media Player for Windows 8 Enterprise N Edition we need to download and install and update from windows update center

The Update is named as Description of the Microsoft Windows Media Feature Pack for N and KN Versions of all Windows 8 Editions 

KB Number :- KB2703761

Link to Download :-

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Raj Trivedi
Member Level:
Member Status: Member,MVP
Member Since: 6/16/2012 2:04:41 AM
Country: India
Regard's Raj.Trivedi "Sharing is Caring" Please mark as answer if your Query is resolved
Raj Trivedi i.e. me started my career as Support Professional and then moved on the Software development eventually reached at these skills Software Development | Enthusiastic Blogger | Content Writer | Technical Writer | Problem Solver | Lecturer on Technology Subjects | Runnerup Award Winner on and firm believer in Sharing as a way of Caring Yet this much achieved its still a long way to go and there is biggest dream lying to be one of the best entrepreneurs of India in Technology Department. The Dream has just started and i hope it follows. Highlights are mentioned in details in my profile at

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)