当我尝试播放音频时,会出现此错误
2010-08-27 09:13:40.466 VoiceRecorder [1]原因失败:操作无法完成。 (OSStatus 错误-43.)
这是什么意思
我正在将文件存储在 Iphone Document 文件夹中,并在我的数据库中复制其名称
所以,当我从数据库中播放它时,它正确获取文件路径
和文件和数据库中的文件名完美地连接但无法播放
2010-08-30 12:22:00.592 VoiceRecorder [2] /Users/Username/Library/Application Support/iPhone Simulator/4.0.1/Applications/4BF0B5C7-59C9-462F-94EC- 662EBCE8505E/Documents/30Aug10_12_21_58.aif 2010-08-30 12:22:00.593 VoiceRecorder [3] 30Aug10-43.)21_58.aif 2010-08-30 12:22:00.618 VoiceRecorder [4]原因失败:操作无法完成。 (OSStatus 错误-43.)
急需回复
这是我的代码
-(IBAction)playevent{
VoiceRecorderAppDelegate *appDelegate=(VoiceRecorderAppDelegate*)[[UIApplication sharedApplication]delegate];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *fullpath = [documentsDir stringByAppendingPathComponent:appDelegate.filenamefrompath];
NSFileManager *fileManager = [NSFileManager defaultManager];
// Check if the database has already been created in the users filesystem
BOOL success = [fileManager fileExistsAtPath:fullpath];
// If the database already exists then return without doing anything
if(success) { NSLog(@"Yes exists"); }else{ NSLog(@"no"); }
//return [documentsDir stringByAppendingPathComponent:appDelegate.filenamefrompath];
NSError* err;
NSLog(@"%@",fullpath);
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:fullpath] error:&err];
//NSString *filePath = [[NSBundle mainBundle] pathForResource:appDelegate.filenamefrompath ofType:@"aif"];
// NSURL * fileURL = [[7] initFileURLWithPath:filePath]; // player = [[8] initWithContentsOfURL:fileURL error:nil];
NSLog(@"%@",appDelegate.filenamefrompath);
player.delegate = self;
if( err ){
//bail!
NSLog(@"Failed with reason: %@", [err localizedDescription]);
}
[player play];
}
请检查我的代码是否有错误