Use the mciSendString API. In the following example, you will need to make a series of CommandButton. It might be a good idea to change the caption to the correct function.
code for module.
Code:
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Put this code in a CommandButton
Code:
'Opens the file
mciSendString "open C:\MyMIDI.mid type sequencer alias background", 0, 0, 0
Put this in another CommandButton
Code:
' Plays the midi
mciSendString "play background", 0, 0, 0
Put this code in another CommandButton
Code:
'Pauses the midi
mciSendString "pause background", 0, 0, 0
Put this code in another CommandButton
Code:
'Closes the file
mciSendString "close background", 0, 0, 0
Always make sure that you Close the file before exiting the program because it will contiune to play until Windows sends a message for the program to stop. This means that if you exit your App while the music is playing, it will still contiune to play. So to prevent this, aslways close the file when you are done.