If you can't find what you need using the site search on the toolbar above, or if you need more detailed help or just need to be pointed in the right direction, post your question to the newly opened kadaitcha.cx forums. Membership is free.

How to Play a .wma, .mp3 or other Music

Visual Basic 2008 can load the Windows Media Player library (WMPLib) and play any supported audio file without needing to load the Windows Media Player interface.


Add a reference to Windows Media Player wmp.dll

Sample Code

Dim dr As DialogResult
OpenFileDialogMP As New OpenFileDialog

OpenFileDialogMP.Filter = "Windows Media Audio (wma)|*.wma|MPEG3 (mp3)|*.mp3"

dr = OpenFileDialogMP.ShowDialog

dr <> Windows.Forms.DialogResult.OK Then
    Exit Sub
End If

Player.URL = OpenFileDialogMP.FileName
Player.settings.volume = 80

To use the sample code, create a Windows Forms project and paste the code into a Button on the default form, then add this line in the Form Class:

Private Player As New WMPLib.WindowsMediaPlayer

Download Sample Project

Also See

How to Play a .wav Sound or System Sound
How to Host Windows Media Player to Play Music & Video

All code examples on this site have been developed for .Net Framework 3.5