Hi there I'm trying to calculate the duration of an AIF file, could you have a quick look at this code please and tell me where im going wrong. I'm developing this on the iPhone. The result is always 0. Thanks in advance.
+ (UInt64)getAudioFileDuration:(NSString*)soundPath { NSURL *afUrl = [NSURL fileURLWithPath:soundPath]; AudioFileID fileID; OSStatus result = AudioFileOpenURL((CFURLRef)afUrl, kAudioFileReadPermission, 0, &fileID); UInt64 outDataSize = 0; UInt32 thePropSize = sizeof(UInt64); result = AudioFileGetProperty(fileID, kAudioFilePropertyEstimatedDuration, &thePropSize, &outDataSize); AudioFileClose(fileID); return outDataSize; }
....
NSLog(@"why is this always 0? %qu", [MySoundClass getAudioFileDuration:@"openPage.aif"]);
|