如何解决除一个以外的所有问题

How to address all except one

在我的 Swift iOS 应用程序中,我需要快速播放不同的声音。每个触发的声音都需要停止所有其他声音,因此一次只能播放一个声音。 我用了

for player in audioPlayerBT{ player.stop()}
audioPlayerBT[playedNote].numberOfLoops = -1
audioPlayerBT[playedNote].play()

在开始新声音之前停止所有声音。这确实有效,但有一个非常非常短的停顿。我想在停止其他声音之前启动新声音以使其更流畅。

你能从

中排除一个索引吗
for player in audioPlayerBT{ player.stop()}

为了启动新音效后使用?

如果您想避免阻止特定玩家,请考虑:

for (index, player) in audioPlayerBT.enumerated() {
    if index != playedNote {
        player.stop()
    }
}