小编Ajh*_*lam的帖子

如何在iOS 11上的Swift中获取FLAC文件元数据?

我需要获取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文件.任何帮助将不胜感激.

ios flac swift

8
推荐指数
2
解决办法
373
查看次数

标签 统计

flac ×1

ios ×1

swift ×1