3

1つのHtmlページがあります。このHtmlページに1つのビデオを表示していますが、このビデオはアプリケーションのWebビューには表示されませんが、デフォルトのブラウザーに表示されます。問題の原因を教えてください。以下は私のコードとビデオです。htmlファイルはsdcardに保存されています。英語のコミュニケーションが悪いのでごめんなさい。

MainActivity.java

public class MainActivity extends Activity {

    WebView webPage;
    Button next;
    String rootDir = "file://" + Environment.getExternalStorageDirectory()
            + "/iR-unzip/testbook/";
    WebChromeClient webChromeClient = new WebChromeClient();
    WebViewClient webViewClient = new WebViewClient();

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

        webPage = (WebView) findViewById(R.id.webview);
        webPage.setWebChromeClient(webChromeClient);
        webPage.setWebViewClient(new MyWebViewClient());
        webPage.getSettings().setJavaScriptEnabled(true);
        webPage.getSettings().setPluginsEnabled(true);
        webPage.getSettings().setPluginState(PluginState.ON);
        webPage.getSettings().setLoadWithOverviewMode(true);
        webPage.getSettings().setUseWideViewPort(true);

        webPage.loadUrl(rootDir + "/" + "chapter_1.html");
        next = (Button) findViewById(R.id.page_changer);
        next.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                webPage.loadUrl(rootDir + "/" + "chapter_2.html");
            }
        });

    }

    public class MyWebChromeClient extends WebChromeClient {

        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            // TODO Auto-generated method stub
            super.onShowCustomView(view, callback);
            if (view instanceof FrameLayout) {
                FrameLayout frame = (FrameLayout) view;
                if (frame.getFocusedChild() instanceof VideoView) {
                    VideoView video = (VideoView) frame.getFocusedChild();
                    frame.removeView(video);
                    video.start();
                }
            }

        }
    }

    public class MyWebViewClient extends WebViewClient {

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

HTMLページ:-

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <title>Chapter 1 for testBook</title>

</head>
<body>
<div style="width: 600px;margin: 0 auto;">
<div id="text"> 
<p><h4>WSDL for client access</h4>
A WSDL service description provides all the information that is required to use a web
service. The T320 version of Eclipse incorporates the Web Tools Platform (WTP),
which provides support for generating a client based on the information inside a
WSDL.
<h4>OU demo services</h4></h4>
<p>At the OU there is a small set of toy web services. These can be accessed using a
client in the same way as you tested the 'Hello' web service using Eclipse. In fact, one
of the web services hosted is a copy of the 'Hello' service.</p>
<img src="Caterpillar-Insect-Animal-Macro-HD-600x375.jpg" />

<p>Click on the 'Browse' button at the top of the box. This will take you to the dialogue box shown in Figure 11.</p>
<img src="images.jpg" />
</div>
<div>
<h3>HTML5 Video : </h3>
<video width="320" height="240" controls="controls">
  <source src="video.mp4" type="video/mp4">Your browser does not support the video tag.
</video>

</div>
</div>
</body>
</html>
4

1 に答える 1

2

この行を置き換えます

  wb.getSettings().setPluginState(PluginState.ON);

これで

  wb.getSettings().setPluginState(WebSettings.PluginState.ON);
于 2012-12-07T12:01:39.607 に答える