使用目标c阅读MP3信息

Ton*_*lon 11 iphone xcode metadata objective-c mpnowplayinginfocenter

我有mp3存储在iPhone上的文件,我的应用程序应该能够读取ID3信息,即以秒为单位的长度,艺术家等.有没有人知道如何在Objective-C中使用或使用哪些库?

非常感谢您的想法.

rpe*_*ich 19

可以kAudioFilePropertyInfoDictionary使用AudioFileGetPropertyAudioToolbox框架的功能读取ID3信息,以检索音频文件的属性.

有关详细说明,请访问iphonedevbook.com

编辑:原始链接现在已关闭.InformIT有一些类似的示例代码,但它并不完整.

  • [此StackOverflow答案很明确,并提供了源代码.](http://stackoverflow.com/a/17478117/59913) (2认同)

Joh*_*eek 5

查看Media Player框架:

这要求所讨论的MP3是手机上iPod库的一部分.

例如,确定手机上每个媒体文件的名称(包括电影,播客等):

MPMediaQuery *everything = [[MPMediaQuery alloc] init];

NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *item in itemsFromGenericQuery) {
    NSString *itemTitle = [item valueForProperty:MPMediaItemPropertyTitle];
    // ...
}
Run Code Online (Sandbox Code Playgroud)

似乎可以使用以下属性:

  • MPMediaItemPropertyMediaType
  • MPMediaItemPropertyTitle
  • MPMediaItemPropertyAlbumTitle
  • MPMediaItemPropertyArtist
  • MPMediaItemPropertyAlbumArtist
  • MPMediaItemPropertyGenre
  • MPMediaItemPropertyComposer
  • MPMediaItemPropertyPlaybackDuration
  • MPMediaItemPropertyAlbumTrackNumber
  • MPMediaItemPropertyAlbumTrackCount
  • MPMediaItemPropertyDiscNumber
  • MPMediaItemPropertyDiscCount
  • MPMediaItemPropertyArtwork
  • MPMediaItemPropertyLyrics
  • MPMediaItemPropertyIsCompilation

不经过媒体播放器框架这样做会有些困难,需要一个外部框架.

  • 他不能使用e Media Player,因为这些文件是他的应用程序文档文件夹中的MP3,而不是系统范围音乐集合中的音乐. (2认同)