A few days ago, you need to play a midi music Loop in a Delphi applet. Why not MP3 or WAV or other? Because the MIDI format is small in size. (In short I have my inevitable reason, more spray nonsense meaning)
The playback feature is selected using the mciSendString function in MMSystem, and notice that the "OPEN" operation requires the media type "type SEQUENCER" (that is, MIDI audio), and then use the "Play XX REPEAT"Operation want to be able to loop playback, the results not only did not realize the cycle, and music is not playing at all. Check MSDN found that "REPEAT" parameter only applies to video media, sequencer, etc. does not apply, there is no way to do it?
Online access to know can be implemented in the "mm_mcinotify" callback event, just for a loop to deal with callbacks, the display does not meet the minimalist style of doing things. Continue Google (Fortunately, the company has a VPN), and finally find the cattle to provide answers (portals), the practice is too clever: since MSDN said repeat parameter only for video, then I will let you play by the video, a MIDI music is not a video of the picture? So the method is in the "OPEN" operation when the media type is specified as "typeMPEGVideo" (Other video formats can also be OK, I do not want to try more), done!
The key code is as follows:
mciSendString (' OPEN music.mid TYPE mpegvideo ALIAS BGM ', nil, 0, 0); mciSendString (' PLAY BGM REPEAT ', nil, 0, 0);
Resources:
Http://www.developerfusion.com/thread/41619/repeatloop-midi
The simplest way to implement MIDI music looping (not to process in MCI callbacks)