简体   繁体   中英

how to play swf file from sd card in my android application?

i play swf file from my asset fold but i want to play it from my sd card...

   String html = "<object width=\"1008\"height=\"550\"> <param name=\"movie\" value=\"file:///android_asset/chem1.swf\"> <embed src=\"file:///android_asset/chem1.swf\" width=\"1008\"height=550\"> </embed> </object>";
     // <param name=\"movie\" value=\"file:///android_asset/absorptionofmineralsalts.swf\"> <embed src=\"file:///android_asset/absorptionofmineralsalts.swf\"> </embed>";

   String mimeType = "text/html";

   String encoding = "utf-8";
   myWebView = (WebView) findViewById(R.id.swfview);

   // WebView wv=(WebView) findViewById(R.id.swfview);
   myWebView.getSettings().setSupportZoom(false);
   myWebView.getSettings().setJavaScriptEnabled(true);
   myWebView.getSettings().setPluginsEnabled(true);
   // wv.getSettings().setPluginState(PluginState.ON);
   myWebView.getSettings().setAllowFileAccess(true);
   WebViewClient webViewClient = new WebViewClient();
   myWebView.setWebViewClient(webViewClient);
   myWebView.setInitialScale(100);

   // wv.loadData(html, mimeType, encoding);
   // wv.getSettings().setJavaScriptEnabled(true);  
   myWebView.loadDataWithBaseURL("null", html, mimeType, encoding,  "");

Try this :

   if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
       System.exit(4);
   } else {
       mWebView.loadUrl("file://" + Environment.getExternalStorageDirectory() + "/swf2.html");
   }

For more reference follow this link :

How to Play local swf files in a webview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM