I can not seem to override the AVAudioSession category or port when audio is being played from a WKWebView. The same code works perfectly when using a normal UIWebView.
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
I've also tried activating the sharedInstance
like this, but it did not help:
[session setActive: YES error: nil];
The above code has no effect on audio coming from a WKWebView. I did find some reports on Twitter that iOS 8.1 is mixing WKWebView audio with background app audio, but I couldn't find the source for that. See this twitter thread for reference: https://twitter.com/marcoarment/status/530881842900373504