May be a simple question, but I am trying to use Spotify's API which is documented in Objective C but I have been working on it in Swift as far as I can.
@property (nonatomic, readonly, copy) NSArray *genres is one of their API protocols for the SPTartist class, however; I can't figure out how to use it in a working manner in swift.
Here is example code of something I have gotten to work.
func updateTrackLength(){
if player?.currentTrackMetadata == nil {
trackLength.text = ""
return
}
let length = player?.currentTrackMetadata[SPTAudioStreamingMetadataTrackDuration] as Int
let convert = length / 60
let remainder = length % 60
var newlength = String(convert)
var newRemainder = String(remainder)
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.trackLength.text = "Track length: " + newlength + " Minutes " + newRemainder + " Seconds"
})
}
This uses the currentTrackMetaData and whatever SPT protocol to track the string output. When I try using SPTArtistGenres or SPTArtistGenre in place of SPTAudioStreamingMetaDataTrackDuration, it does not work. To specify my question, I want to use the currentTrackMetaData to call the genres property up above. Any advice is greatly appreciated!