Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

How to disable/hide Audio Controls on lock screen from WkWebView

Hi,

I am trying to remove the audio controls for my app on the lock screen. Since I use WKWebView, there are 3 audio tags in my html and I play and pause em via JS. However, if I do not play any sound since app launch, there are no audio controls on the lock screen. But if I play one of those 3 files (they are even less then 3 Sec sound effects e.g. for buttons) the audio controls appears on lock screen. Note even when the sounds on pause() or not playing they were listed on the lock screen.

What I have tried so far without success

MPNowPlayingInfoCenter.default().nowPlayingInfo = [:]

and

``try audioSession.setCategory(.playback, mode: .default, options: [])
            try audioSession.setActive(false, options: .notifyOthersOnDeactivation)``

and

UIApplication.shared.endReceivingRemoteControlEvents()

Another problem is that the app scales with iOS system settings "display zoom". Is there a way to deny it?

It is latest Xcode verion 16.3 and iOS 18. I have no background mode in my Capabilities. Nothing worked so far. Has anyone an idea?

Greetings

Accepted Answer

Hi folks,

found a solution by delegating a JS function to the Scene.

audio.src = ""
to sceneWillResignActive

and the other way back with reinit the audio.src to local mp3

Someone has an idea how to deny the iOS Settings zoom display property?

How to disable/hide Audio Controls on lock screen from WkWebView
 
 
Q