I am developing music app but for lock screen control i am not able to assign time duration and elapsed time
here is my code
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.previousTrackCommand.isEnabled = true;
commandCenter.previousTrackCommand.addTarget(self, action:#selector(home_ViewController.btn_rewind(_:)))
commandCenter.nextTrackCommand.isEnabled = true
commandCenter.nextTrackCommand.addTarget(self, action:#selector(home_ViewController.btn_fast(_:)))
commandCenter.playCommand.isEnabled = true
commandCenter.playCommand.addTarget(self, action:#selector(home_ViewController.play_player))
commandCenter.pauseCommand.isEnabled = true
commandCenter.pauseCommand.addTarget(self, action:#selector(home_ViewController.pause_player))
commandCenter.togglePlayPauseCommand.isEnabled = true
commandCenter.togglePlayPauseCommand.addTarget(self, action:#selector(home_ViewController.togglePlay_Pause))
commandCenter.skipBackwardCommand.isEnabled = false
commandCenter.skipForwardCommand.isEnabled = false
if #available(iOS 9.1, *) {
commandCenter.changePlaybackPositionCommand.isEnabled = true
} else {
// Fallback on earlier versions
return
}
and media info
func setLockInfo()
{
let url = URL(string: song_UrlString)
let data = try? Data(contentsOf: url!)
let art = MPMediaItemArtwork.init(image: UIImage(data: data!)!)
let songInfo :[String : Any] = [MPMediaItemPropertyTitle :st_title,MPMediaItemPropertyArtwork : art]
MPNowPlayingInfoCenter.default().nowPlayingInfo = songInfo
}
I am getting title and image but lock screen is not displaying time
I am using SWIFT 3 to code