I want to put a web into webview.These is a video in the web.The video’s format is wmv.I put the web in the android project “assets” file.Now I can scan the web,but the video can’t play.This is the code on below.Who can help me?Thanks.
public class WebViewActivity extends Activity {
private WebView webview;
private WebSettings webSettings;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webView);
webSettings = webview.getSettings();
webSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setBuiltInZoomControls(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setPluginState(PluginState.ON);
webview.getSettings().setPluginsEnabled(true);
webview.loadUrl("file:///android_asset/demo/html/demo.html");
webview.setWebViewClient(new MyWebClient());
}
private class MyWebClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
WMV is a proprietary Microsoft video format. Chances are Android doesn’t have a codec for it. You should convert it to something standard e.g H264.
Unfortunately video encoding is a minefield of proprietary tech. There are a few open source converters available. FFMPEG is probably the most extensive. There’s a handy GUI for this called WinFF (if you’re using windows).
You can test your HTML file by putting it and your video onto the SDcard and see if it works in it’s simplest form. Try with different video formats as a sanity check.