Dear Masters' VB
Please help me, How can I play music file MP3 in VB?
Many thanks for your help.
Printable View
Dear Masters' VB
Please help me, How can I play music file MP3 in VB?
Many thanks for your help.
There are 3 ways you could do it--each having a different level of complexity.
1. Use the shell function to launch your MP3 with Window's mplayer or mplayer2.
2. Add the MS Multimedia control to a form.Code:Shell ("mplayer.exe /play C:\your.mp3", vbMinimizedNoFocus)
3. Make direct use of the Window's multimedia API calls.Code:MMControl1.Wait = True
MMControl1.FileName = "C:\your.mp3"
MMControl1.Command = "Open"
Code:Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Sub Command1_Click()
mciExecute ("play c:\your.mp3")
End Sub
Gerald M.
[This message has been edited by Gerald (edited 12-15-1999).]
hey,
the third funsction does not work is there anything wrong with it or is it just my stupid machine.
mciExecute (a simplified version of mciSendString) will fail if the path to the file contains spaces (isn't in DOS 8.3 format). Use GetShortPathName to returns a valid path/file name.