在 masm32 中播放一个声音文件并同时停止另一个声音文件
Play a sound file in masm32 and to stop the other sound file at the same time
所以我正在用汇编语言做一个游戏,我正在使用 PlaySound()
函数来播放背景歌曲。我想在我"die"进入游戏后,另一个声音文件开始播放一个声音文件,同时停止另一个背景歌曲。
阅读文档。
pszSound
A string that specifies the sound to play. The maximum length, including the null terminator, is 256 characters. If this parameter is NULL, any currently playing waveform sound is stopped. To stop a non-waveform sound, specify SND_PURGE in the fdwSound parameter.
...
fdwSound
Flags for playing the sound. The following values are defined.
...
SND_ASYNC
The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
因此您需要调用 PlaySound()
三次 - 一次开始背景音乐,一次停止背景音乐,一次播放下一个声音。
invoke PlaySound,offset "the name of the bkgnd file",NULL,SND_ASYNC
...
invoke PlaySound,NULL,NULL,SND_ASYNC
invoke PlaySound,offset "the name of the other file",NULL,SND_ASYNC
所以我正在用汇编语言做一个游戏,我正在使用 PlaySound()
函数来播放背景歌曲。我想在我"die"进入游戏后,另一个声音文件开始播放一个声音文件,同时停止另一个背景歌曲。
阅读文档。
pszSound
A string that specifies the sound to play. The maximum length, including the null terminator, is 256 characters. If this parameter is NULL, any currently playing waveform sound is stopped. To stop a non-waveform sound, specify SND_PURGE in the fdwSound parameter....
fdwSound
Flags for playing the sound. The following values are defined.
...
SND_ASYNC
The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
因此您需要调用 PlaySound()
三次 - 一次开始背景音乐,一次停止背景音乐,一次播放下一个声音。
invoke PlaySound,offset "the name of the bkgnd file",NULL,SND_ASYNC
...
invoke PlaySound,NULL,NULL,SND_ASYNC
invoke PlaySound,offset "the name of the other file",NULL,SND_ASYNC