I tryed to play videos on WKWebView after the following codes.
1. Set AVAudioSessionCategory to SoloAmbient
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient)
}
catch let error as NSError {
print(error)
}
Error was not print.
2. Called setActive(true)
do {
try AVAudioSession.sharedInstance().setActive(true)
}
catch let error as NSError {
print(error)
}
Error was not print.
3. Checked current AVAudioSessionCategory
print("audioSession.category = \(AVAudioSession.sharedInstance().category)")
Output:
audioSession.category = AVAudioSessionCategorySoloAmbient
But, WKWebView ignores status of Ring/Silent switch, outputs video sound even if state of the switch is Silent.
I thought that this behavior is like AVAudioSessionCategoryPlayback.
UIWebView does not ignore.
Is there a solution?
I use devices below.
iPhone 5s : iOS 8.4.1
iPhone 6 plus : iOS 9.