Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to play an mp3 file 1

Status
Not open for further replies.

Ablecken

Programmer
Jun 5, 2001
130
US
I know how to play a wav file in vb. But how do you play a mp3? or any other sound format for that matter?
 
Actually you can. You have to use the Multimedia control for that (which comes with VB). I did create one a long time ago using codes I found on the internet(it was on another forum). I think you can find some help for that on the microsoft site. Although the help file I found was specific to MP3 files.

I'll try to find the adress back for you.

Cheers ''Life is like a box of chocolate...''
 
Nevermind i figured it out. its really easy. if anybody wants to know let me know and ill post it.
 
Sure Ablecken. There is always 1000's of ways to do something, but I'd like to see your solution. ''Life is like a box of chocolate...''
 
YA ablecken I am working on a vb project right now any info on how to play a mp3 file inside a a vb program would be most useful
 
Ok, here goes.

Under components I had a Windows Media Player OCX:
windows\system\msdxm.ocx
It's an older version, 6.4. Im trying to find the 7.0 or 7.1. Heres the code.

first of all i have just a plain common dialog control called cmd. Open a file with it. I use this: (bye the way, if there is a better way please tell all of us.)
Code:
' CancelError is True.
   On Error Resume Next
   ' Set filters.
   cmd.Filter = "All Files (*.*)|*.*|MP3 Files (*.mp3)|*.mp3|Wav Files (*.wav)|*.wav"
   ' Specify default filter.
   cmd.FilterIndex = 2

   ' Display the Open dialog box.
   cmd.DialogTitle = "Open"
   cmd.ShowOpen

I then have the windows media player called mp1. i use this code to play it.

Code:
mp1.FileName = cmd.FileName
mp1.Play

Thats it. There is probably a more efficient way to do it but i was just using for simple purposes. You can play, stop, fastfoward, rewind, and pause all kinds of files. video and audio. my player on my form is very small so you cant see the controls and such.

Thats it :)

Ablecken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top