When the program starts, it initializes the MCI control.
When the user clicks the Play/Stop button, the determines whether it is playing a file. If the program is playing a file, it sets the control's Command to Stop to stop playing. If the program isn't playing a file, it sets the control's FileName property to the name of the MIDI file, sets Wait to True so the control opens the file synchronously, and sets Command = Open to open the file. It then sets Command = Play to play the file. It does not set Wait = True first so the play is asynchronous.
When the control finishes playing, the program closes the file. If the Play button still reads "Stop," the program restarts the file.
|