當我嘗試播放音頻時出現此錯誤無法播放文件中的音頻文件?
2010-08-27 09:13:40.466 VoiceRecorder [3127:207]失敗,原因:操作無法完成。 (OSStatus錯誤-43)。
這是什麼意思
我身體儲存文件在iPhone文檔文件夾,並在我的數據庫複製其名稱
所以當我曾經從數據庫中玩它得到正確文件路徑
從文件和數據庫CONCAT完美,但無法和文件名玩
2010-08-30 12:22:00.592 VoiceRecorder [8140:207] /用戶/用戶名/庫/ Application Support/iPhone模擬器/ 4.0.1 /鴨錄音機/ 4BF0B5C7-59C9-462F-94EC- 662EBCE8505E/Documents/30Aug10_12_21_58.aif 2010-08-30 12:22:00.593 VoiceRecorder [8140:207] 30Aug10_12_21_58.aif 2010-08-30 12:22:00.618 VoiceRecorder [8140:207]失敗,原因:操作無法完成。 (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 = [[NSURL的alloc] initFileURLWithPath:文件路徑]。 // player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
NSLog(@"%@",appDelegate.filenamefrompath);
player.delegate = self;
if(err){
//bail!
NSLog(@"Failed with reason: %@", [err localizedDescription]);
}
[player play];
}
請檢查我的代碼錯誤
肯定的NSLog(@ 「%@」,FULLPATH);給我這個結果 /用戶/用戶/庫/應用程序支持/ iPhone模擬器/ 4.0.1 /應用程序/ 4911A7B9-E121-43FF-8C4A-BABC73BD523B/Documents/30Aug10_01_25_29.aif – 2010-08-30 09:24:51
是的我已跟蹤它所在的文件IPHONE SIMULATOR文檔文件夾 – 2010-08-30 09:26:26