简体   繁体   中英

How to detect the playing state of the audio in UIWebView in iOS?

I have an UIWebView to load a web link: http://myqq.com in my iOS app. I don't know how to detect the playing state of the audio in UIWebView.

I just need to know whether the audio in UIWebView is playing or not in my iOS app, so that I can do something.

I have searched a lot from Stackoverflow and Google, but I can't find a satisfied answer. Can anyone give me some help?

You can check if audio is playing with isOtherAudioPlaying

So in your UIWebView delegate methods you can use:

BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];

AVAudioSession has a sharedInstance property which you can utilize in this instance. The property is a BOOL and can be updated upon multiple threads.

@tnylee's code is perfect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM