获取Swift中曲目的元数据



我正在Xcode-Swift-Spotify项目上工作,我唯一想要的是获得有关当前正在播放的歌曲的信息,我的意思是名称,专辑等信息,我已经尝试了很多不同的方法,但我不能得到它。请帮帮我。下面有一个例子

func audioStreaming(audioStreaming: SPTAudioStreamingController!, didStartPlayingTrack trackUri: NSURL!)
{
    SPTTrack.trackWithURI(self.player?.currentTrackURI, session: spotifyAuthenticator.session) { (error:NSError!, track:AnyObject!) -> Void in
        print(track.name)
    }}

我忘了说,我正在使用Spotify SDK

我给你看我的例子

 var avpItem = AVPlayerItem(URL: megaURL)
            var commonMetaData = avpItem.asset.commonMetadata as! [AVMetadataItem]
            for item in commonMetaData {
                if item.commonKey == "title" {
                    songTitle = item.stringValue
                }
                if item.commonKey == "artist" {
                    songArtist = item.stringValue
                }
                if item.commonKey == "album" {
                    songAlbum = item.stringValue
                }
                if item.commonKey == "artwork" {
                    songArtworkData = item.dataValue
                }

元数据的关键字

let AVMetadataCommonKeyTitle: String
let AVMetadataCommonKeyCreator: String
let AVMetadataCommonKeySubject: String
let AVMetadataCommonKeyDescription: String
let AVMetadataCommonKeyPublisher: String
let AVMetadataCommonKeyContributor: String
let AVMetadataCommonKeyCreationDate: String
let AVMetadataCommonKeyLastModifiedDate: String
let AVMetadataCommonKeyType: String
let AVMetadataCommonKeyFormat: String
let AVMetadataCommonKeyIdentifier: String
let AVMetadataCommonKeySource: String
let AVMetadataCommonKeyLanguage: String
let AVMetadataCommonKeyRelation: String
let AVMetadataCommonKeyLocation: String
let AVMetadataCommonKeyCopyrights: String
let AVMetadataCommonKeyAlbumName: String
let AVMetadataCommonKeyAuthor: String
let AVMetadataCommonKeyArtist: String
let AVMetadataCommonKeyArtwork: String
let AVMetadataCommonKeyMake: String
let AVMetadataCommonKeyModel: String
let AVMetadataCommonKeySoftware: String

最新更新