获取设备声音输出的当前音量 - iOS

Get current volume of device sound output - iOS

我正在我的应用程序的背景中播放一首歌曲(使用 AVAudioPlayer),我希望一些小节像在 Garageband 中一样上下弹跳,您可以在其中设置曲目的音量。我想知道如何获取当前播放歌曲的音量,而不是设备设置的音量。

提前致谢

您问的是计量,而不是音量。请参阅 AVAudioPlayer 的文档。您需要使用各种 API 进行计量,例如 meteringEnabledaveragePowerForChannel:.

Apple 提供了一个示例应用程序来演示这一点。见 avTouch sample app.

您可以在 Stack Overflow 上找到大量讨论。参见 these search results