我已经成功获得有关当前播放歌曲的信息,但是当歌曲改变时,第二首歌曲的信息不会被录制。如何让程序录制多首歌曲?
let nowPlaying = MPMusicPlayerController.systemMusicPlayer().nowPlayingItem
let playing = MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo
let Title = nowPlaying.valueForProperty(MPMediaItemPropertyTitle) as! String
let Artist = nowPlaying.valueForProperty(MPMediaItemPropertyArtist) as! String
let Album = nowPlaying.valueForProperty(MPMediaItemPropertyAlbumTitle) as! String
let duration = nowPlaying.valueForProperty(MPMediaItemPropertyPlaybackDuration) as! NSNumber
let change = nowPlaying.valueForProperty(MPMusicPlayerControllerNowPlayingItemDidChangeNotification) as! String
class ViewController: UIViewController {
var ID3 = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
var ID3 = UILabel(frame: CGRectMake(0,0,400,400))
ID3.center = CGPointMake(160, 284)
ID3.textAlignment = NSTextAlignment.Center
ID3.text = (("Song: " + Title) + "\n" + ("Artist: " + Artist) + "\n" + ("Album: " + Album))
ID3.numberOfLines = 3
self.view.addSubview(ID3)
//prints into the console what song is currently playing
println("Song: " + Title)
println("Artist: " + Artist)
println("Album: " + Album)
println(change)