gpt4 book ai didi

objective-c - Cocoa:获取信息并播放 mp3

转载 作者:行者123 更新时间:2023-12-03 17:14:44 24 4
gpt4 key购买 nike

最简单的方法是什么:

  1. 从文件系统加载 mp3
  2. 获取 mp3 比特率元数据
  3. mp3 文件大小
  4. 在 iTunes 上播放 mp3

与 cocoa ?

我目前只有文件路径。

谢谢

最佳答案

对于元数据,您可以使用 MDItem .

MDItem is a CF-compliant object that represents a file and the metadata associated with the file.

MDItemRef metadata = MDItemCreate(NULL, (CFStringRef)@"/Users/parag/0.mp3");
NSNumber *audioBitrate = (NSNumber *)MDItemCopyAttribute(metadata, kMDItemAudioBitRate);
NSLog(@"audioBitrate:%i", [audioBitrate intValue]);

文件大小

[[[NSFileManager defaultManager] attributesOfItemAtPath:@"/Users/parag/0.mp3" error:nil] fileSize];  

在 iTunes 上播放 mp3

NSString *cmd = @"open -a /Applications/iTunes.app '/Users/parag/0.mp3'";
system([cmd UTF8String]);

关于objective-c - Cocoa:获取信息并播放 mp3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10089431/

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