gpt4 book ai didi

objective-c - 从 m4a 或 wav 解析标题?

转载 作者:行者123 更新时间:2023-11-29 13:24:52 27 4
gpt4 key购买 nike

如何在 iOS (objective-c) 上轻松解析 wav 或 m4a 文件中的标题?

感谢您提供解决方案。

最佳答案

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);

}

关于objective-c - 从 m4a 或 wav 解析标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13399231/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com