iphone: – 用UILocalNotification声音播放录制的声音
发布时间:2020-12-14 19:44:40 所属栏目:百科 来源:网络整理
导读:我能够使用avrecorder录制语音,但它将录制的语音保存在文档目录的路径中,我无法找到在localNotification声音中使用它的方法,所以任何一个plz都能解释这个问题 录音代码: – -(IBAction)startRecording{ AVAudioSession *audioSession = [AVAudioSession sha
我能够使用avrecorder录制语音,但它将录制的语音保存在文档目录的路径中,我无法找到在localNotification声音中使用它的方法,所以任何一个plz都能解释这个问题
录音代码: – -(IBAction)startRecording { AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *err = nil; [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err]; NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentPath = [searchPaths objectAtIndex:0]; NSLog(@"ccc...%@",documentPath); if(toggle) { toggle = NO; recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey]; strRecordedVoice=[NSString stringWithFormat: @"%.0f.%@",[NSDate timeIntervalSinceReferenceDate] * 1000.0,@"caf"]; recordedTmpFile = [NSURL fileURLWithPath:[documentPath stringByAppendingPathComponent:strRecordedVoice]]; NSLog(@"Using Filepath called: %@",recordedTmpFile); NSLog(@"Using str: %@",strRecordedVoice); recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error]; [recorder setDelegate:self]; [recorder prepareToRecord]; [recorder record]; progressView.progress = 0.0; [recorder recordForDuration:(NSTimeInterval) 2]; lblStatusMsg.text = @"Recording..."; progressView.progress = 0.0; timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(handleTimer) userInfo:nil repeats:YES]; } else { toggle = YES; //Stop the recorder. [recorder stop]; } } //用于本地通知的代码 -(void) scheduleLocalNotificationWithDate:(NSDate *)fireDate { UILocalNotification *notification =[[UILocalNotification alloc]init]; notification.fireDate=fireDate; notification.repeatInterval = 0; notification.alertAction = NSLocalizedString(@"View",@"View"); notification.soundName = UILocalNotificationDefaultSoundName; NSDictionary *userDict = [NSDictionary dictionaryWithObject:ap.strAlarmTitle forKey:kRemindMeNotificationDataKey]; notification.userInfo = userDict; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; [notification release]; } Reference:-you can see it its an alarm application which uses uilocalnotification itunes.apple.com/us/app/record-alarm-free/id418511936?mt=8 解决方法
您只能使用App捆绑包中的声音进行本地通知
source (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |