我需要获取FLAC文件的元数据.我试过以下代码:
let item = AVPlayerItem(url: URL(fileURLWithPath: path))
let commonMetadata = item.asset.commonMetadata
songInfo[ARTIST_NAME] = "Unknown"
songInfo[GENRE_NAME] = "Unknown"
songInfo[ALBUM_NAME] = "Unknown"
songInfo[PLAY_COUNT] = "0"
for metadataItem in commonMetadata {
switch metadataItem.commonKey?.rawValue ?? "" {
case "type":
songInfo[GENRE_NAME] = metadataItem.stringValue
case "albumName":
songInfo[ALBUM_NAME] = metadataItem.stringValue
case "artist":
songInfo[ARTIST_NAME] = metadataItem.stringValue
default: break
}
}
Run Code Online (Sandbox Code Playgroud)
但这不适用于FLAC文件.任何帮助将不胜感激.