WKWebView do not work with AVAudioSession

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.

same issue, and it's concerning that there's been no reply on this yet as it seems like this is something they just don't want to support

Has there been any update on this issue? This post is almost 2 years old

Over 3 years later and no action on this. Really pathetic.

Has anyone ever filed an Apple feedback report with a feature request/bug report? Apple developers don't normally read these forums, and, if they do, they can't take unilateral action based on forum requests. You need to file a bug report. Link at bottom of page "Report Bugs"

WKWebView do not work with AVAudioSession
 
 
Q