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