对于我正在使用的音频
- (void)viewDidLoad {
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"Music" ofType: @"m4a"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
self.audioPlayer = newPlayer;
[newPlayer release];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
if (self.audioPlayer) {
[self updateViewForPlayerInfo];
[self updateViewForPlayerState];
[self.audioPlayer setDelegate:self];
}
[fileURL release];
[super viewDidLoad];
}
并且设置了plist“应用程序播放音频”,
按下主页时播放背景声音,但来自多任务切换器或锁定屏幕的遥控器不起作用,背景音频无法暂停或转发/倒带。
怎么了?
谢谢!