UIWebView的截距QUOT;设定电影路径:"从JavaScript的音频播放器 [英] UIWebView intercept "setting movie path:" from javascript audio player

查看:178
本文介绍了UIWebView的截距QUOT;设定电影路径:"从JavaScript的音频播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 4的,我有加载一个UIWebView通过一段JavaScript音频播放器的页面。我没有创建这个播放器,它是由第三方拥有,所以我不能修改它。当我点击播放按钮,我看到的NSLog打印类似如下:

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

我的问题是,什么是得到它的电影路径设置,如何拦截呢?音频将继续发挥,直到我创建另一个的UIWebView,或者使用内置的由iPhone home键双击访问音响控制,或关闭应用程序。我不能拦截与 shouldStartLoadWithRequest路径:,JavaScript函数 audio.play()出现调用一些内置在播放器直接。我想来控制和音频是如何被打了,但短期解析HTML为任何其中p音频> 标签,我无法弄清楚如何抓住这条道路,并指出它不是默认的某个地方。

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.

推荐答案

UIWebView的基本上是WebKit的包装。苹果不希望你碰任何有关它比由现有的委托方法提供的。

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.

这就是说,你可以通过注入的JavaScript修改任何加载文档的DOM。这样,您还可以修改audio.play不做任何事情,而是获取URL用自己的播放器,你可以控制播放。

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.

这篇关于UIWebView的截距QUOT;设定电影路径:&quot;从JavaScript的音频播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆