我使用Cordova 3.6.3构建了一个使用界面声音的iOS应用程序。当您单击按钮时,应用程序会弹奏一个简短的"单击" -sound。这非常有效。但当我在另一个应用程序的背景上播放音乐时我使用我的应用程序时会发生这种情况: 背景音乐消失了。 2.播放界面声音。 3.背景音乐消失了。
这不是它应该发生的方式。我想在背景音乐仍然开启时播放界面声音。我需要更改为Cordova / Phonegap才能更改此行为?有AVAudioSession的东西吗?
感谢您的帮助。
答案 0 :(得分:1)
我在 CDVSound.m 中找到了解决方案。
旧版
NSString* sessionCategory = bPlayAudioWhenScreenIsLocked ? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient;
[self.avSession setCategory:sessionCategory error:&err];
新版本
NSString* sessionCategory = bPlayAudioWhenScreenIsLocked ? AVAudioSessionCategoryAmbient : AVAudioSessionCategoryAmbient;
[self.avSession setCategory:sessionCategory error:&err];