In this article I will explain with an example, how to use Windows Media Player in Windows Forms (WinForms) Application using C# and VB.Net.
Adding Windows Media Player to Toolbox
Open Visual Studio and Right Click inside the Toolbox and select Add Tab option from the Context Menu.
The Add Tab Button will add a new Tab in the Toolbox and you will need to set a suitable name to it.
Now inside the newly created Tab, you need to Right Click and click Choose Items… from the Context Menu.
Then look for the Windows Media Player within the COM components tab of the Choose Toolbox Items window.
Finally, Click OK and the Windows Media Player control will now be added to the Visual Studio Toolbox.
Video File Location
The Video file is stored inside the disk Folder (Directory).
Form Design
Now drag drop the Windows Media Player to the Form.
Playing Video (MP4) File in Windows Forms using C# and VB.Net
Inside the Form Load event, the path of the video file is set to the media player URL property.
C#
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"E:\Files\Butterfly.mp4";
}
VB.Net
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
axWindowsMediaPlayer1.URL = "E:\Files\Butterfly.mp4"
End Sub
Screenshot
Downloads