







|
VB Mania |

|
Play an MIDI File |
|
Information: In this example, you will be able to play wave files using the great mciSendString function to dictate the computer to play a specific MIDI file |
|
Illustration:
|
|
What You Need?: 1. One Form named Form1 2. Two CommandButtons: one named cmdPlay (caption: "Play MIDI") the other named cmdStop (caption: "Stop MIDI") |
|
Private 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
Private Sub cmdPlay_Click() result = mciSendString("open C:\windows\Media\onestop.mid type sequencer alias canyon", 0&, 0, 0) result = mciSendString("play canyon", 0&, 0, 0)
End Sub
Private Sub cmdStop_Click() result = mciSendString("close all", 0&, 0, 0) End Sub |
|
Code:
|
|
Explanation: CommandButton cmdPlay will evoke the mciSendString using some string parameters, ”open FULL_MIDI_PATH-NAME type sequencer alias canyon” , where FULL_MIDI_PATH-NAME is dictate the full path of the MIDI file to be played. Where as CommandButton cmdStop will commence playing stoppage. |
|
Hint: · To fulfill the widespread use of the useful mciSendString function, I’m planning to dedicate a fully whole section about it. |

|
Wait for the update… Coming Soon... |
|
Sponsored Links |