How to play video in android?

I want to put the website in webview. This video is online. The video format is wmv.I puts the website in the "assets" file of the Android project. Now I can scan on the Internet, but the video can't play. This is the code 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; } } } 
+1
source share
2 answers

WMV is Microsoft's proprietary video format. Most likely, Android does not have a codec for it. You must convert it to something standard, like H264.

Unfortunately, video encoding is a minefield of proprietary technology. There are several open source converters. FFMPEG is probably the most extensive. There a convenient graphical interface for this is called WinFF (if you use windows).

You can test your HTML file by placing it and your video on an SD card and see if it works in its simplest form. Try using different video formats as a health check.

+2
source

WMV is widely supported on Android devices, but there are various tools for converting the format.

https://gist.github.com/3718414 is a sample showing the Android Android browser and HTML5 that works with video codecs supported by Android (.mp4 is best for progressive video because it has the widest support)

+1
source

Source: https://habr.com/ru/post/1492658/


All Articles