2010-12-14 62 views

回答

0

RadioAlarm,我几乎可以肯定,能够静音时,因为它使本身在后台运行播放。对于NORMAL本地通知(即即使在应用程序结束后也会触发的通知),我还没有找到克服静音开关或铃声音量的方法。

+1

你知道的一种方式对本地通知播放音频警报,但播放.wav文件不在捆绑?例如,如果我录制我的声音,上面写着“买牛奶”,并且我将通知设置为下午2点..我收到通知,但我希望声音在没有用户干预的情况下播放。 – smorhaim 2011-02-22 05:44:44

+0

Apple明确不允许您访问不在捆绑中的.wav文件。所以,由于您不允许在不破坏签名的情况下删除捆绑中的文件。因此,无法播放您的套餐中未包含的声音。 – 2012-03-21 15:07:04

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]; 
    }