我正在游戏。我有一些问题。

我使用系统声音来确认播放器,当他/她按下一个按钮时。当其他声音正在播放时,这些声音尊重播放器设置的卷(我使用AVAudioPlayers和AudioQueues)。但是,当系统声音只是播放时,它会忽略播放器设置的音量并在铃声卷上播放。

如何强制系统声音尊重玩家设置的卷即使没有其他声音播放?

有帮助吗?

解决方案

How are your players (I assume you mean the people playing the game) setting the volume -- through the device's volume control, or through your app interface? If the latter, then this won't work, since system sounds should always play at the device volume.

According to the Multimedia Programming Guide, "Sounds play at the current system audio volume, with no programmatic volume control available."

I don't know why your system sounds would change volume when an AVAudioPlayer sound is playing. If that's the case, can you loop a silent sound with AVAudioPlayer when you're not playing other sounds? Otherwise I would try playing all sounds with AVAudioPlayer so that you have direct control over the volume.

其他提示

Assuming you are meaning that players are setting the volume using the side volume buttons on the device:

I had the same problem getting SystemSound to respect the volume buttons but found a setting in "Settings"/"Sounds"/"Ringer and Alerts"/"Change With Buttons" that was "OFF" by default. Switching that to "ON" made it work.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top