I am using AVFoundation framework and more specifically
AVPlayer
along with AVPlayerItem
to play an audio content. I am also setting AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
, AVAudioSession.sharedInstance().setActive(true)
, MPNowPlayingInfoCenter.default().nowPlayingInfo = // some value
and using MPRemoteCommandCenter
commands. As usual it is showing a default player on iPhone lock screen as shown in figure.My question is once the playback of audio is finished the default iPhone lock screen player does not goes away. I am resetting all the above info e.g
AVAudioSession.sharedInstance().setActive(false)
and MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
and audioPlayer.replaceCurrentItem(with: nil)
etc. How can I make this lock screen player hide after the playback is finished.