I have a UIWebView to download an html web link: http://myqq.com in my iOS application. I do not know how to determine the audio playback status in UIWebView.
UIWebView
I just need to know if the sound is playing in the UIWebView or not in my iOS application, so I can do something.
I searched a lot with Stackoverflow and Google, but I cannot find a satisfied answer. Can anyone help me out?
You can check if sound is playing using isOtherAudioPlaying
isOtherAudioPlaying
So, in your UIWebView delegate methods, you can use:
BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
AVAudioSession has a sharedInstance property that you can use in this instance. The property is BOOL and can be updated across multiple threads.
AVAudioSession
sharedInstance
@tnylee code is perfect.