1
A
답변
1
NSBundle* bundle = [NSBundle mainBundle];
NSString* path = [bundle bundlePath];
NSURL * fileURL=[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/silence.mp3", path]];
AudioFileTypeID fileTypeHint = kAudioFileMP3Type;
NSString *fileExtension = [[fileURL path] pathExtension];
if ([fileExtension isEqual:@"mp3"]||[fileExtension isEqual:@"m4a"])
{
AudioFileID fileID = nil;
OSStatus err = noErr;
NSDictionary *piDict = nil;
UInt32 piDataSize = sizeof(piDict);
err = AudioFileGetProperty(fileID, kAudioFilePropertyInfoDictionary, &piDataSize, &piDict);
if(err != noErr) {
[piDict release];
NSLog(@"AudioFileGetProperty failed for property info dictionary");
}
NSString * Album = [piDict objectForKey:
[NSString stringWithUTF8String: kAFInfoDictionary_Album]];
NSString * Artist = [piDict objectForKey:
[NSString stringWithUTF8String: kAFInfoDictionary_Artist]];
NSString * Title = [piDict objectForKey:
[NSString stringWithUTF8String: kAFInfoDictionary_Title]];
NSLog(@"%@",Title);
NSLog(@"%@",Artist);
NSLog(@"%@",Album);
}
정규식을 사용해 보셨습니까? 동일한 질문, 당신은 무엇을 시도 했습니까? – brianLikeApple
나는이 방법으로 만 시도하지만 mp3에서만 작동합니다. – flatronka
CFDictionaryRef piDict = nil; UInt32 piDataSize = sizeof (piDict); err = AudioFileGetProperty (fileID, kAudioFilePropertyInfoDictionary, & piDataSize, & piDict); if (err! = noErr) { NSLog (@ "AudioFileGetProperty가 속성 정보 사전에 실패했습니다."); } NSDictionary * nsDict = (__bridge NSDictionary *) piDict; NSString * title = [nsDict objectForKey : [NSString stringWithUTF8String : kAFInfoDictionary_Title]]; – flatronka