【原创】android webview 加载网络视频

webView.loadUrl(video_url);
webView.setInitialScale(50);
WebSettings setting = webView.getSettings();
setting.setUseWideViewPort(true);
        setting.setJavaScriptEnabled(true); //Support JavaScript
        setting.setPluginsEnabled(true); //Support Plugins, for example just like flash plugin.
        setting.setSupportZoom(true); //Zoom Control on web (You don't need this if ROM supports Multi-Touch  
        setting.setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM
        

        webView.setWebViewClient(new MyWebViewClient());



public class MyWebViewClient extends WebViewClient  {      

private ProgressDialog loadingBar;


@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
loadingBar=ProgressDialog.show(mActivity, null, "正在加载…");
super.onPageStarted(view, url, favicon);
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);  // webview里面的链接还在同一个页面中加载 
        return true;  
}


@Override
public void onPageFinished(WebView view, String url) {
if(loadingBar.isShowing()){
loadingBar.dismiss();
       }
super.onPageFinished(view, url);
}         
  
@Override
       public void onReceivedError(WebView view, int errorCode,
               String description, String failingUrl) {
           Toast.makeText(mActivity, "加载出错!", Toast.LENGTH_LONG).show();
           final AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
           alertDialog.setTitle("ERROR");
           alertDialog.setMessage(description);
           alertDialog.setButton("OK", new DialogInterface.OnClickListener(){
               @Override
               public void onClick(DialogInterface dialog, int which) {
                alertDialog.dismiss();
               }
           });
           alertDialog.show();
       }
     }

你可能感兴趣的:(JavaScript,android,网络,String,url,plugins)