I need to get metadata of an FLAC file. I tried following code:
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
}
}
But this is not working for a FLAC file. Any help will be appreciated.