I'm trying to make a radio app with Swift. And I have problem with remote controls on the lock screen. Simply doesn't work - nothing on the screen. The code from the ViewController:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
playButton.setTitle("Play", forState: UIControlState.Normal)
if NSClassFromString("MPNowPlayingInfoCenter") != nil {
let image:UIImage = UIImage(named: "logo_player_background")!
let albumArt = MPMediaItemArtwork(image: image)
var songInfo: NSMutableDictionary = [
MPMediaItemPropertyTitle: "Radio Brasov",
MPMediaItemPropertyArtist: "87,8fm",
MPMediaItemPropertyArtwork: albumArt
]
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = songInfo as [NSObject : AnyObject]
}
if (AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)) {
println("Receiving remote control events")
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
} else {
println("Audio Session error.")
}
}
Even after fixing MPNowPlayingInfoCenter
line, nothing appears on the lock screen. What I'm doing wrong?
the code is from tutorial