
-----------------------------------
RaLz
Thu Jun 10, 2004 4:59 pm

How to play midi files for my game
-----------------------------------
how do i do this i need to know how and quickly!!!!

-----------------------------------
Brightguy
Thu Jun 10, 2004 9:40 pm

Re: How to play midi files for my game
-----------------------------------
Well there are two ways that I know of...  
Using Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private lngMciErr As Long

Private Sub Form_Load()
    lngMciErr = mciSendString("open FILENAME type sequencer alias mid1", 0&, 0&, 0&)
    lngMciErr = mciSendString("play mid1", 0&, 0, 0)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    lngMciErr = mciSendString("close mid1", 0&, 0&, 0&)
End Sub
Or you can just use the Microsoft Multimedia Control - add it to your project through the menu Project > Components...
Private Sub Form_Load()
    MMControl1.Filename = FILENAME
    MMControl1.Command = "Open"
    MMControl1.Command = "Play"
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MMControl1.Command = "Close"
End SubYou can set MMControl1.Visible = False if you don't want to see the control on the form.
