开发者

How to get the value of a HTML5 video tag src attribute in Android

My application have a WebView. The WebView HTML has:

<video id="player" src="rtsp://somesite/videofile.mp4"开发者_如何转开发 >Video content</video>

How can I get the src attribute from this HTML?

I want to have the URI of this video. It's needed to play in my video player. I don't want to use VideoView.


You can:

yourWebView.loadUrl("javascript:document.getElementById('player').doSomething..

If you want to get the value out of your WebView, use

/* Register a new JavaScript interface called JSInterface */  
yourWebView.addJavascriptInterface(new MyJavaScriptInterface(), "JSInterface");
yourWebView.loadUrl("javascript:window.JSInterface.setSrc(document.getElementById('player').src)");

setSrc is a method in your Java class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜