Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use webview play local video?
    primarykey
    data
    text
    <p>i use the browser to open the HTML file, video play is normal. but can't play in webview. The following is my android code and HTML code.</p> <p>android code:</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WebChromeClient chromeClient = new WebChromeClient(); String url = new String("file:///android_asset/content0.html"); WebView mWebView = (WebView) findViewById(R.id.webView); mWebView.setWebChromeClient(chromeClient); HelloWebViewClient hwc = new HelloWebViewClient(); mWebView.setWebViewClient(hwc); mWebView.getSettings().setJavaScriptEnabled(true); hwc.shouldOverrideUrlLoading(mWebView,url); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if(url.indexOf(".3gp")!=-1 || url.indexOf(".mp4")!=-1 || url.indexOf(".flv")!=-1){ Intent intent=new Intent("android.intent.action.VIEW",Uri.parse(url)); view.getContext().startActivity(intent); return true; }else{ view.loadUrl(url); return true; } } } </code></pre> <p>}</p> <p>html code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;/head&gt; &lt;body id="page"&gt; &lt;div id="VideoBean" style="position:relative;" width="305" height="242"&gt; &lt;video id="video" controls="controls" width="305" height="242"&gt;&lt;source id="source" src="Sun_1-1.mp4"&gt; &lt;/video&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I don't know where is wrong, but there is certainly a problem, who can tell me? thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload