How to Play MIDI Files
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 'MultiMedia - How to Play MIDI Files Option Explicit 'Add a module to your project and Insert the following 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 'Add 2 CommandButtons to your form one is to play Midi file and another to stop playing the Midi File. Private Sub Command1_Click() 'To start playing the midi file Call mciSendString("open " & "C:\WINDOWS\Media\onestop.mid" & " type sequencer", 0&, 0, 0) End Sub Private Sub Command2_Click() 'To stop playing the midi file Call mciSendString("stop " & "C:\WINDOWS\Media\onestop.mid", 0&, 0, 0) Call mciSendString("close " & "C:\WINDOWS\Media\onestop.mid", 0&, 0, 0) End Sub |