How to determine sound playback status in UIWebView in iOS?

I have a UIWebView to download an web link: http://myqq.com in my iOS application. I do not know how to determine the audio playback status in 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?

+1
source share
2 answers

You can check if sound is playing using isOtherAudioPlaying

So, in your UIWebView delegate methods, you can use:

 BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying]; 
0
source

AVAudioSession has a sharedInstance property that you can use in this instance. The property is BOOL and can be updated across multiple threads.

@tnylee code is perfect.

0
source

All Articles