Media Player Tutorial in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This tutorial will show you how to make a media player program in visual basic .NET.

I am using Visual Basic 2008 Express Edition for this tutorial.

We will add one control that is not included in the toolbox:

On the Toolbox: right click the mouse and click on Choose Items.

Visual Basic 2008 Add WinSock

A Window will appear: Click on COM Components.

Scroll down to Windows Media Player and check it then click ok. windows media player tutorial

In the toolbox, scroll down to the new control "Windows Media Player and drag it to the form:

visual basic .net windows media player tutorial

Resize it to fit the form like the picture below and make sure to leave a space between the icon and Windows Media Player:

vb,net media player program

Change some properties of the Windows Media Player. Right click on it and then click on properties. On the properties window, change the Anchor property to Top, Bottom, Left, Right.

windows media player tutorial

That property will make Windows Media Player stretches to the whole window when the form size maximizes.

Add a button to the form and change it's text property to "Song": step by step to program a windows media player

Add OpenFileDialog to the form:

Right click on OpenFileDialog1 in the gray area and click on properties. Change it's Filter property to Music File|*.mp3

Add the "Song" Button Click Event:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
End Sub

When you play the program, click on Song button and that should show you a Open File Dialog to choose a song. Make sure that the song is in mp3 format.

Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.