[英]How to Halt Sound Effect in SDL2
How would I halt the playing of a sound effect in SDL2?如何在 SDL2 中停止播放音效?
Currently I'm playing sound effects using the SDL2 Mixer with this code.目前我正在使用带有此代码的 SDL2 混音器播放音效。
Mix_PlayChannel(-1, soundEffect, 0);
However I want the play to be able to not have to listen to the entire sound effect and when they leave the menu the sound effect should stop.但是我希望播放能够不必听整个音效,并且当他们离开菜单时音效应该停止。
I've tried Mix_HaltMusic();
我试过
Mix_HaltMusic();
however that doesn't seem to apply to Mix_Chunk
.但是,这似乎不适用于
Mix_Chunk
。
How would I do so?我该怎么做?
To stop the Mix_Chunk
started with Mix_PlayChannel
, you have to use Mix_HaltChannel
as explained in this answer for the opposite problem.要停止以
Mix_Chunk
开始的Mix_PlayChannel
,您必须使用Mix_HaltChannel
,如this answer中针对相反问题的解释。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.