Listening .mp3 Files by clicking a button

New1

Member
Joined
Dec 5, 2005
Messages
9
Programming Experience
1-3
Hello,

Does anyone know how can i listen an .mp3 file (from a specific path) when i push a button?
For example, when i push a button (btnSound) i would like to open and listen an mp3 file from my hard disk (C:\project\myMP3.mp3)

Thank you in advance

New1
 
O, I know all about it. There are many ways to do it but my personal opinion and way to go is with DirectX. It's built for developers specifically and the sound quality rocks. However; it does have some known glitches that you will have to learn and build your own code to handle if they occurr and it dosn't support wma very well if at all. MS offers the free SDK download so you can see exactly how to implement it into your code. If you need more help let me know. :)


O yeah, other ways to accomplish this is by using Windows Media Player SDK; RealPlayer SDK; ect.... just google some scenarios. As far as just playing mp3 with the sound class in .net, I think it only offers wav sound playback. But I have never messed with it to know.


And if you have no idea of how to use DirectX then download the SDK anyways and i'll walk you through it. (Be Patient, it's a huge download)
 
You can do that by using Windows Media Player.
I assume that you created new project with blank form.Well,let's start.:)
First,right click on your toolbox and select Customize Toolbox...Now in tab COM Components find and check Windows Media Player and click OK.Then
select MediaPlayer control and add it to your form.After that from toolbox
add OpenFileDialog control.Now add a button and double click on it.Enter following code:

Dim FilePath As String
Dim FileName As String
OpenFileDialog1.Filter = "MP3s (*.MP3)|*.MP3"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
FilePath = OpenFileDialog1.FileName
AxMediaPlayer1.Open(OpenFileDialog1.FileName)
End If

Compile your code and have fun.:)
 
Back
Top