Play mp3 soundeffect from vb.net std

swu

Active member
Joined
Mar 26, 2005
Messages
33
Programming Experience
1-3
I'm looking for a simple way to play an mp3 from within an app.

Any suggestions?
 
Sample Code?

I added the windows media player control, made it not visible, but I need some help with some sample code to play the mp3 through it.

I'm using vb.net std 2003.

Thanks in advance.
 
Here's the relevant MSDN topic if you want all the details. It think the main members you would be interested in would be URL, which is the fully qualified path of the current media file, and Ctlcontrols, which contains methods to control playback.
 
Actually, if you don't want to give the user any control then it probably isn't appropriate to add the player control to the form and make it not visible. You should probably try creating the object in code instead and never actually adding it to the form at all. I believe that it should still be able play media files but you'd need to test that.
 
Actually, that's very simple just use a URL of wmp object ... i.e. axWinMedPlayer.URL = path



VB.NET:
Dim[/color][/size][size=2] Result [/size][size=2][color=#0000ff]As[/color][/size][size=2] DialogResult
Result = OpenFileDialog1.ShowDialog()
 
[/size][size=2][color=#0000ff]If[/color][/size][size=2] Result = DialogResult.OK [/size][size=2][color=#0000ff]Then
 
[/color][/size][size=2]myPlayer.URL = OpenFileDialog1.FileName
 
[/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If

Also, take a look at the attached project below i guess you will find it useful ... Cheers ;)

ops ... sorry i haven't set up the OFD's options ... i guess you can do that by yourself in order to make it sort/filter only certain file types (mp3, wav ...)
 

Attachments

  • WindowsPlayer.zip
    17.1 KB · Views: 38
Last edited:
Back
Top