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

我怕爱的太早我们不能终老 提交于 2019-12-12 09:13:49

问题


I have an UIWebView to load a html web link:http://m.y.qq.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?


回答1:


You can check if audio is playing with isOtherAudioPlaying

So in your UIWebView delegate methods you can use:

BOOL isOtherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];



回答2:


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.



来源:https://stackoverflow.com/questions/33240647/how-to-detect-the-playing-state-of-the-audio-in-uiwebview-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!