views:

9

answers:

1

when ever i try to play audio this error appears

2010-08-27 09:13:40.466 VoiceRecorder[3127:207] Failed with reason: The operation couldn’t be completed. (OSStatus error -43.)

what does it mean

I am physically storing file in Iphone Document folder and copying its name in my database

so when ever I play it from database its correctly get file path

and file name from document and database concat perfectly but unable to play

2010-08-30 12:22:00.592 VoiceRecorder[8140:207] /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[8140:207] 30Aug10_12_21_58.aif 2010-08-30 12:22:00.618 VoiceRecorder[8140:207] Failed with reason: The operation couldn’t be completed. (OSStatus error -43.)

need an urgent reply

here is my code

-(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:filePath]; // player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];

NSLog(@"%@",appDelegate.filenamefrompath);
player.delegate = self;

if( err ){
    //bail!
    NSLog(@"Failed with reason: %@", [err localizedDescription]);
}


[player play];

}

Please check my code for error

A: 

The code looks OK on the surface

Strangely tracking down the errors definitions is not entirely easy

They are in MacErrors.h

fnfErr = -43, /*File not found*/

Can you verify that the URL you are feeding the player in [NSURL fileURLWithPath:fullpath] is valid.

And more to the point is the file you are trying to play there in the Sim folder?

and off topic if this is supposed to be an IBAction then the signature should be
-(IBAction)playevent:(id)sender

Warren Burton
yes NSLog(@"%@",fullpath); give me this result /Users/USER/Library/Application Support/iPhone Simulator/4.0.1/Applications/4911A7B9-E121-43FF-8C4A-BABC73BD523B/Documents/30Aug10_01_25_29.aif
STUPID PROGRAMMER
YES i have trace the file it is in IPHONE SIMULATOR DOCUMENT FOLDER
STUPID PROGRAMMER
Problem solved This error occurs because i am using date time function to give file name so when ever i store file physically its give name like tHis 17_52_01( hh_mm_SS)and when i store files in database data function give other name to the same file like 17_52_02 (hh_MM_SS)anyway thanks for such a quick replyPROBLEM SOLVED
STUPID PROGRAMMER