OSStatus e;
// initialize the audio session. don't know if you already do this.
e = AudioSessionInitialize(NULL, NULL, NULL, NULL);
if (e)
{
NSLog(@"failed to start audiosession: %i", (int)e);
}
// ***********************************************************
// * THIS IS THE CODE THAT MAKES OTHER AUDIO BE ABLE TO PLAY *
// ***********************************************************
UInt32 category = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);
// ***********************************************************
// * HOORAY *
// ***********************************************************
// activate the audio session. don't know if you already do this.
e = AudioSessionSetActive(YES);
if (e)
{
NSLog(@"failed to make audiosession active: %i", (int)e);
}
这是我用来在我的游戏中播放声音而不会在后台中断音乐的代码。但是,现在大多数都被弃用了。我在iOS 7中用什么替换它?