StackOverflow I want to trying read current playing song from control center in ios7+ using swift lang In objective-c I could read it using this code
NSDictionary *nowPlaying = @{MPMediaItemPropertyArtist: currentTrack.artist,
MPMediaItemPropertyAlbumTitle: currentTrack.title};
But I don't know how write song_info_getter method in swift P.s. I couldn't find similar question on SO
Specifically, I'm having trouble getting the current track info. (artist/album/etc)
I've made this on desktop (mac):
func get_iTunes_data() {
NSDistributedNotificationCenter.defaultCenter().addObserver(self, selector: "allDistributedNotifications:", name: "com.apple.iTunes.playerInfo", object: "com.apple.iTunes.player")
}
var now : String = ""
func allDistributedNotifications (note : NSNotification) {
let userInfo:NSDictionary = note.userInfo as NSDictionary
println(userInfo)
}
But I don't know how to make like this for iOS