Hi,
By setting app's AVAudioSession's category to `AVAudioSessionCategoryPlayback` with option `mixWithOthers`, should be able to make sounds from video in web view be mixed with third party background music (such as Apple Music or Spotify).
It works well with UIWebView but do not work at all once switch to WKWebView.
// Sample code
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSessionCategoryPlayback, with: .mixWithOthers)
try audioSession.setActive(true) } catch { print(error) }
} catch {
print(error)
}
// WKWebView
let webview = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 300))
self.view.addSubview(webview)
// Load a page with video
webview.load(URLRequest(url: URL(string: "http://www.ultimedia.com/deliver/generic/iframe/mdtk/01509739/src/8l50lp/ad/yes")!))
// end of viewDidLoad()
Any idea or workaround? Thanks a lot.