Since I updated to ios 12.2 lockscreen controls stopped to work for me and I can't figure out why. It worked fine in ios 12.1
- App has enabled
capabilities->Background mores -> Audio
- I set
UIApplication.shared.beginReceivingRemoteControlEvents()
Then I set
MPRemoteCommandCenter.shared().playCommand.isEnabled = true MPRemoteCommandCenter.shared().pauseCommand.isEnabled = true MPRemoteCommandCenter.shared().playCommand.addTarget(self, action:#selector(self.playPlayer)) MPRemoteCommandCenter.shared().pauseCommand.addTarget(self, action: #selector(self.pausePlayer))
Then
AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) and AVAudioSession.sharedInstance().setActive(true)
I use AVPlayer
and AVPlayer
item. Locksceen controls never show up on ios 12.2. Any idea what can be causing this issue? Thanks
(I use xcode 10.2 and swift 4.2)
EDIT: I was able to figure out that this happens only when device is online. If I play immediately, lockscreen controls will show up and then disappear in few seconds. If I play later, they will not show up. So it seems they work few seconds after app start and then don't
EDIT 2: Fixed now. Issue was caused by app loading local html file into webview. Completely unrelated to playback but that's it. Solution is not to load webview