We have a game that is very close to being released, but we have one extremely annoying problem. One on of our Beta testers phones, he can't hear any of the in game sound effects. He can, however, hear the background music and the title screen music just fine.
我们有一个非常接近发布的游戏,但我们有一个非常烦人的问题。在我们的Beta测试者手机中,他听不到任何游戏声音效果。然而,他可以听到背景音乐和标题屏幕音乐。
The background and title music are both being played via AVAudioPlayer (they are longer, we need looping and volume control, etc). The sound effects are simply being played with AudioServicesPlaySystemSound (they are very short, we don't need precise control or to know when they end, etc). This works on most iPhones, but not on this one. All of this is being played with an audio session of AVAudioSessionCategorySoloAmbient.
背景和标题音乐都是通过AVAudioPlayer播放的(它们更长,我们需要循环和音量控制等)。使用AudioServicesPlaySystemSound简单地播放声音效果(它们非常短,我们不需要精确控制或知道它们何时结束等)。这适用于大多数iPhone,但不适用于此。所有这些都是通过AVAudioSessionCategorySoloAmbient的音频会话进行的。
So I have two questions: - First, is this an acceptable implementation? i.e. is there something I missed that says you can't mix these two frameworks, or a reason why its a bad idea to mix them? - Second, has anyone seen something like this before? If so, did you find a way around it?
所以我有两个问题: - 首先,这是一个可接受的实施方案吗?即是否有一些我错过的东西说你不能混合这两个框架,或者为什么混合它们的坏主意呢? - 第二,有没有人见过这样的事情?如果是这样,你找到了解决方法吗?
Additional background note: I can pretty conclusively say that on his phone, it is the mixing of the two frameworks. He was able to hear sounds until roughly the same build where we added the title screen music. Also, if I change one of the sounds to work through an AVAudioPlayer, he's able to hear it. Unfortunately, I can't simply move the sounds into AVAudioPlayers because it just doesn't perform well at all, and I need better synchronization.
附加背景说明:我可以非常确切地说,在他的手机上,这是两个框架的混合。他能够听到声音,直到我们添加标题屏幕音乐的大致相同的构建。此外,如果我通过AVAudioPlayer更改其中一个声音,他就能听到它。不幸的是,我不能简单地将声音移动到AVAudioPlayers中,因为它根本不能很好地运行,我需要更好的同步。
2 个解决方案
#1
8
I have two apps on the app store that mix those two frameworks. AVAudioPlayer for sounds that require start and stop and volume control and AudioServices toolbox for short little beeps and clicks. The only think I can think of, off the top of my head, is that the volume of AVAudioPlayer seems to be controlled separately from the AudioServices sounds. So check to make sure that the tester doesn't have sounds turned off (with the vibrate mode switch) or the volume turned way down.
我在应用程序商店中有两个应用程序混合这两个框架。 AVAudioPlayer用于需要启动和停止以及音量控制的声音,而AudioServices工具箱用于短暂的哔哔声和点击。我能想到的唯一想法是,AVAudioPlayer的音量似乎与AudioServices声音分开控制。因此,请检查以确保测试仪没有关闭声音(使用振动模式开关)或音量调低。
If this doesn't help, tell me more about your sounds/code and I can add some code to my app to see if I can get the same behavior. Of course, sounds like most your testers don't have this problem, and I probably won't see it either.
如果这没有帮助,请告诉我有关您的声音/代码的更多信息,我可以在我的应用中添加一些代码,看看我是否可以获得相同的行为。当然,听起来像你的大多数测试人员没有这个问题,我也许也不会看到它。
#2
9
EDIT 2:
I've determined the cause of the error. The two different audio frameworks play on two different volume settings. There is the main volume (that's what shows up once you are in the app, and has no title on it) and the ringer volume (that's what shows up when you're on the home screen without any app loaded). The AVAudioPlayer calls play with the main volume setting. As I have set the category to AVAudioSessionCategorySoloAmbient (see code below), this is the volume control that will be adjusted if you use the volume rocker inside the app. The SystemSounds, however, are played at the Ringer Volume. This will NOT come up inside the app, and as such does not allow the user to adjust their settings during the game.
编辑2:我已经确定了错误的原因。两种不同的音频框架在两种不同的音量设置上播放。有一个主音量(一旦你在应用程序中显示的内容,并且没有标题)和铃声音量(当你在主屏幕上没有加载任何应用程序时显示的内容)。 AVAudioPlayer调用主音量设置播放。由于我已将类别设置为AVAudioSessionCategorySoloAmbient(请参阅下面的代码),因此如果您在应用程序中使用音量摇杆,则会调整音量控制。但是,SystemSounds是在铃声音量下播放的。这不会出现在应用内部,因此不允许用户在游戏中调整其设置。
It's easy to see the possible confusion for the user: Let's say they have their ringer set to low, or even off. They start playing the game. They hear the title screen music (AVAudioPlayer) and are able to turn the volume up or down and it responds normally. Then they start the game and the sound effects play (SystemSounds), and they hear nothing because the ringer volume is low/off. In an effort to hear the sound effects, they bump up the volume and the background music responds accordingly. So from this point of view, it definitely looks like the sound effects just aren't playing.
很容易看出用户可能会感到困惑:假设他们的铃声设置为低,甚至关闭。他们开始玩游戏。他们听到标题屏幕音乐(AVAudioPlayer)并能够上调或下调音量并正常响应。然后他们开始游戏并播放声音效果(SystemSounds),他们什么都听不到,因为铃声音量低/关。为了听到声音效果,他们提高了音量,背景音乐也相应地响应。所以从这个角度来看,它看起来肯定是没有播放的声音效果。
If you have this similar situation, have your user make sure that their ringer volume is up before playing the game and their mute switch is on (i.e. not muted). You can also verify all of this by doing the test yourself - drop your ringer volume and bump your in-app volume up. Your SystemSounds should drop out of the mix.
如果你有类似的情况,请让你的用户在玩游戏之前确保他们的铃声音量已经达到并且他们的静音开关打开(即没有静音)。您也可以通过自己进行测试来验证所有这些 - 降低您的铃声音量并提高您的应用内音量。您的SystemSounds应该从混合中退出。
Original answer: In re-digging through all of the docs, I found the answer. I wasn't properly activating the audio session. Previously I only had this code to set the category:
原始答案:在重新挖掘所有文档时,我找到了答案。我没有正确激活音频会话。以前我只有这个代码来设置类别:
NSError *setCategoryError = nil;
BOOL categoryWasSet = [[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategorySoloAmbient
error: &setCategoryError];
But I needed to also add the following code to explicitly activate the audio session:
但是我还需要添加以下代码来显式激活音频会话:
NSError *activationError = nil;
BOOL activationSuccess = [[AVAudioSession sharedInstance]
setActive: YES
error: &activationError];
I've re-tested with this user, and it has completely fixed the issue. Hope that helps anyone who might have a similar problem.
我已经对这个用户进行了重新测试,它完全解决了这个问题。希望能帮助任何可能遇到类似问题的人。
EDIT: This doesn't seem to have resolved the issue after all. I got a false positive from my tester, and when examined more in detail it seems that he didn't actually hear the SystemSound generated sounds.
编辑:毕竟这似乎没有解决问题。我的测试人员得到了误报,当详细检查时,他似乎并没有真正听到SystemSound产生的声音。
#1
8
I have two apps on the app store that mix those two frameworks. AVAudioPlayer for sounds that require start and stop and volume control and AudioServices toolbox for short little beeps and clicks. The only think I can think of, off the top of my head, is that the volume of AVAudioPlayer seems to be controlled separately from the AudioServices sounds. So check to make sure that the tester doesn't have sounds turned off (with the vibrate mode switch) or the volume turned way down.
我在应用程序商店中有两个应用程序混合这两个框架。 AVAudioPlayer用于需要启动和停止以及音量控制的声音,而AudioServices工具箱用于短暂的哔哔声和点击。我能想到的唯一想法是,AVAudioPlayer的音量似乎与AudioServices声音分开控制。因此,请检查以确保测试仪没有关闭声音(使用振动模式开关)或音量调低。
If this doesn't help, tell me more about your sounds/code and I can add some code to my app to see if I can get the same behavior. Of course, sounds like most your testers don't have this problem, and I probably won't see it either.
如果这没有帮助,请告诉我有关您的声音/代码的更多信息,我可以在我的应用中添加一些代码,看看我是否可以获得相同的行为。当然,听起来像你的大多数测试人员没有这个问题,我也许也不会看到它。
#2
9
EDIT 2:
I've determined the cause of the error. The two different audio frameworks play on two different volume settings. There is the main volume (that's what shows up once you are in the app, and has no title on it) and the ringer volume (that's what shows up when you're on the home screen without any app loaded). The AVAudioPlayer calls play with the main volume setting. As I have set the category to AVAudioSessionCategorySoloAmbient (see code below), this is the volume control that will be adjusted if you use the volume rocker inside the app. The SystemSounds, however, are played at the Ringer Volume. This will NOT come up inside the app, and as such does not allow the user to adjust their settings during the game.
编辑2:我已经确定了错误的原因。两种不同的音频框架在两种不同的音量设置上播放。有一个主音量(一旦你在应用程序中显示的内容,并且没有标题)和铃声音量(当你在主屏幕上没有加载任何应用程序时显示的内容)。 AVAudioPlayer调用主音量设置播放。由于我已将类别设置为AVAudioSessionCategorySoloAmbient(请参阅下面的代码),因此如果您在应用程序中使用音量摇杆,则会调整音量控制。但是,SystemSounds是在铃声音量下播放的。这不会出现在应用内部,因此不允许用户在游戏中调整其设置。
It's easy to see the possible confusion for the user: Let's say they have their ringer set to low, or even off. They start playing the game. They hear the title screen music (AVAudioPlayer) and are able to turn the volume up or down and it responds normally. Then they start the game and the sound effects play (SystemSounds), and they hear nothing because the ringer volume is low/off. In an effort to hear the sound effects, they bump up the volume and the background music responds accordingly. So from this point of view, it definitely looks like the sound effects just aren't playing.
很容易看出用户可能会感到困惑:假设他们的铃声设置为低,甚至关闭。他们开始玩游戏。他们听到标题屏幕音乐(AVAudioPlayer)并能够上调或下调音量并正常响应。然后他们开始游戏并播放声音效果(SystemSounds),他们什么都听不到,因为铃声音量低/关。为了听到声音效果,他们提高了音量,背景音乐也相应地响应。所以从这个角度来看,它看起来肯定是没有播放的声音效果。
If you have this similar situation, have your user make sure that their ringer volume is up before playing the game and their mute switch is on (i.e. not muted). You can also verify all of this by doing the test yourself - drop your ringer volume and bump your in-app volume up. Your SystemSounds should drop out of the mix.
如果你有类似的情况,请让你的用户在玩游戏之前确保他们的铃声音量已经达到并且他们的静音开关打开(即没有静音)。您也可以通过自己进行测试来验证所有这些 - 降低您的铃声音量并提高您的应用内音量。您的SystemSounds应该从混合中退出。
Original answer: In re-digging through all of the docs, I found the answer. I wasn't properly activating the audio session. Previously I only had this code to set the category:
原始答案:在重新挖掘所有文档时,我找到了答案。我没有正确激活音频会话。以前我只有这个代码来设置类别:
NSError *setCategoryError = nil;
BOOL categoryWasSet = [[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategorySoloAmbient
error: &setCategoryError];
But I needed to also add the following code to explicitly activate the audio session:
但是我还需要添加以下代码来显式激活音频会话:
NSError *activationError = nil;
BOOL activationSuccess = [[AVAudioSession sharedInstance]
setActive: YES
error: &activationError];
I've re-tested with this user, and it has completely fixed the issue. Hope that helps anyone who might have a similar problem.
我已经对这个用户进行了重新测试,它完全解决了这个问题。希望能帮助任何可能遇到类似问题的人。
EDIT: This doesn't seem to have resolved the issue after all. I got a false positive from my tester, and when examined more in detail it seems that he didn't actually hear the SystemSound generated sounds.
编辑:毕竟这似乎没有解决问题。我的测试人员得到了误报,当详细检查时,他似乎并没有真正听到SystemSound产生的声音。