This article shows you how to use the windows media player control with microsoft visual studio in VB.NET.

As you know, windows media player activex control is available for windows operating systems, it allows you to open music files, video ..etc.

To practice demo, you should create a new windows forms project, then right click on your project, then add a reference to Windows Media Player.

We will use COM to call windows media player from your windows, then you can play music files or video files. media player

Add axwindowsmediaplayer to your visual studio toolbox, by right-clicking on the General tab of your toolbox->Choose Items

windows media player toolbox

Design a simple windows forms application as the following

windows media player

Add the Windows Media Player control from your visual studio toolbox into your Windows Forms, then resize the control and place it where you want the video window to appear.

Next, 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.