UIWebView intercept “setting movie path:” from javascript audio player

a 夏天 提交于 2019-12-22 08:07:17

问题


In iOS 4, I've got a page loaded in a UIWebView with a javascript audio player. I did not create this player, it is owned by a third party, so I can't tinker with it. When I click the play button, I see an NSLog printout like the following:

setting movie path: http://data.myaudio.com/thefile.mp3

My question is, what is getting it's movie path set and how do I intercept it? The audio will continue to play until I create another UIWebView, or use the built in audio controls accessible by an iPhone home button double tap, or close the app. I can't intercept the path with shouldStartLoadWithRequest:, the javascript function audio.play() appears to call some built in player directly. I'd like to control where and how the audio is being played, but short of parsing the HTML for any <audio> tags, I can't figure out how to grab that path and point it somewhere other than the default.


回答1:


UIWebView is essentially a wrapper for WebKit. Apple does not want you to touch anything more about it than is provided by the existing delegate methods.

That being said, you can modify the DOM of any loaded document by injecting JavaScript. This way you could also modify the audio.play to not do anything and instead get the URL to play with your own player that you can control.



来源:https://stackoverflow.com/questions/4107217/uiwebview-intercept-setting-movie-path-from-javascript-audio-player

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