0
我已经尝试了一切:AVAudioPlayer后台任务不工作[的iOS]
-setup的info.plist 所需的背景模式:应用程序播放音频;
-setup球员:
[[AVAudioSession sharedInstance] setDelegate: self];
// allow app continue to play when the screen is locked
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
error:nil];
UInt32 doSetProperty = 0;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers,
sizeof (doSetProperty),
&doSetProperty
);
// Registers the audio route change listener callback function
AudioSessionAddPropertyListener (
kAudioSessionProperty_AudioRouteChange,
audioRouteChangeListenerCallback,
self
);
// Activates the audio session.
NSError *activationError = nil;
[[AVAudioSession sharedInstance] setActive: YES error: &activationError];
[appSoundPlayer prepareToPlay];
[appSoundPlayer setVolume: 1.0];
[appSoundPlayer setDelegate: self];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
什么我忘了?有什么不对?
你可以发邮件给我你的代码。我一直在努力,它正常工作,第二件事是你在设备上测试它还是只是模拟器。在模拟器的情况下,它不会工作。 – 2012-04-24 09:08:41
请点击此链接http://stackoverflow.com/questions/10276096/cant-beginreceivingremotecontrolevents-in-ios/10278392#10278392。如果即使你没有得到它,那么请给我发电子邮件你的代码,我会解决它insha阿拉,[email protected] – 2012-04-24 09:20:28