As you know, Windows Media Player is available for Windows operating systems, it allows you to open music files, video ..etc. This article will show you how to use Windows Media Player control in Windows Form Application with VB.NET
To practice demo, you should create a new windows forms vb.net project, then right click on your project, then add a reference to Windows Media Player library.
We will use COM to call windows media player from your windows to play music files or video files.
Add windows media control to your toolbox, by right-clicking on the General tab of your toolbox->Choose Items
Design your windows forms as the following
Add the Windows Media Player control to your Form, then resize the control and place it where you want the video window to appear.
Add code to handle your Open button click event
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim ofd As New OpenFileDialog ofd.Filter = "MP3|*.mp3" If ofd.ShowDialog() = DialogResult.OK Then AxWindowsMediaPlayer1.URL = ofd.FileName End If End Sub End Class
Add a filter property to Music File|*.mp3, make sure users only select files that have been filtered
When you play the program, click the Open button->Open File Dialog will show allowing you to choose a song.