Win32的 - 迷笛与MCISendString循环 [英] Win32 - Midi looping with MCISendString
问题描述
我在做一个游戏,我使用MIDI文件的背景音乐。下面是我目前使用的code:
I'm making a game, and I'm using midi files for the background music. Here's the code I'm currently using:
void Game::play_music()
{
// Start the music:
if(map.levelnumber % 2 == 0)
{
mciSendString(L"open MUSIC01.MID type sequencer alias Music1", NULL, 0, NULL);
mciSendString(L"play Music1", NULL, 0, NULL);
playing = "Music1";
} else {
mciSendString(L"open MUSIC02.MID type sequencer alias Music2", NULL, 0, NULL);
mciSendString(L"play Music2", NULL, 0, NULL);
playing = "Music2";
}
}
这个伟大的工程,但它只有一次通过播放歌曲。我试图循环它通过增加回头客,在MCI播放命令,但后来根本不玩什么。哪能循环的音乐?
This works great, except it only plays the song once through. I tried to loop it by adding "repeat" in the mci play command, but then it doesn't play anything at all. How can I loop the music?
推荐答案
我看了一下MSDN上的多媒体命令字符串参考,并发现了
I looked at the multimedia command string reference on MSDN and found out that
TCHAR tch[100];
mciSendString("status [alias] mode", tch, 100, NULL);
将投入是否【别名】正在播放或停止为TCH。如果它停了,我只是用了求[别名]启动命令来重新加载MIDI文件。我应该指出,这会导致延迟,而东西是计算或任何 - 所以,如果你不把它放进一个单独的线程程序将冻结
will put whether [alias] is playing or stopped into "tch". If it's stopped, I just use the "seek [alias] to start" command to reload the midi file. I should mention that this causes a delay while stuff is computing or whatever - so your program will freeze if you don't put this in a separate thread.
这篇关于Win32的 - 迷笛与MCISendString循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!