我正在开发在收到本地通知时需要唤醒的闹钟。但是当设备静音时我什么都听不见,我在问,因为我看到了 2 个实现了该功能的应用程序,即(无线电警报)。谢谢,托默。
问问题
2391 次
3 回答
3
查看AVAudioSession
的setCategory
功能——它应该为您解决问题。
这是有关类别信息的链接:developer.apple.com - 音频会话类别
于 2010-12-16T00:33:59.897 回答
0
RadioAlarm, I'm almost certain, is able to play when muted because it keeps itself running in the background. For a NORMAL local notification (i.e. one that fires even after the app finishes), I have not found a way to overcome the mute switch or the ringer volume.
于 2011-02-08T17:01:51.827 回答
0
-(void)playSound:(NSString *)filePath
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: nil];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:filePath]];
[playerItem addObserver:self forKeyPath:@"status" options:0 context:0];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem];
self.audioPlayer = [[AVPlayer alloc] initWithPlayerItem:playerItem];
[self.audioPlayer play];
}
于 2013-07-02T19:22:17.920 回答