Android - 如何从Webview中的链接播放视频?

时间:2014-09-11 10:11:25

标签: android webview

我想在我的代码中播放链接中的视频。

运行图片

等应用

https://c0109712b82b50aca46ad98aaf358dbbcebc484e.googledrive.com/host/0B2j8iTcQWJncMGJyU1M0UXBYRTA/Untitled.png

点击播放但不起作用:(

我的代码:

public class MainActivity extends ActionBarActivity {

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webView);

    webView.getSettings().setJavaScriptEnabled(true);

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }

    });

    webView.loadUrl("http://m.kenh14.vn/video/secrets-mv-mary-lambert-90692.htm");
}

1 个答案:

答案 0 :(得分:0)

尝试启用javascript

WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);