带有 nil CommonKey 的 AVMetadataItem

AVMetadataItem with nil CommonKey

我正在开发一个应用程序,除其他外,它从文件共享文件夹中读取音频文件,我正在尝试使用关联的元数据从文件中获取尽可能多的信息。

[AVMetadataItem] 中有一些值带有键,我可以使用像

这样的循环读取它们
    for metadataItem in audioAsset.metadata{
        if metadataItem.commonKey == AVMetadataKey.commonKeyArtist{
           print("artistName IN METADATA \(metadataItem.value)")
    }

但是在数组上还有其他一些值为 nil -> Common Key = nil & value = 1/2

我对那个特别感兴趣,因为它给我曲目编号。音频已用 iTunes 编辑,所以我期待匹配的 AVMetadataKey。

我还意识到,如果我打印键值,我会得到类似 "TPE1" 的东西,它代表艺术家。有没有相关的文档?

-有什么遗漏吗?

-编辑元数据的最佳方式是什么?

-如果我有一个编辑文件的 UIViewController,我可以添加元数据值吗?

谢谢

我写了一个 class returns .mp3、.alac 和 .aac 文件的元数据。由于关联的元数据不同,因此需要以不同方式检索它们。

查看结果here

唯一的事情是用 URL 初始化 class,它将管理流程和处理错误。