I'm having problems with this. If I go to an SWF directly in the browser, it works fine. If I attempt to use loadUrl on an SWF file it stays blank and loads nothing.
I have used this example to test this code and confirm it works. In this example the qualibus.swf is in contained within the assets of the app. Please test this on an actual device, as on the emulator it show a blank page (probably the flash player is not present on the emulator)
Test3Activity.java:
package com.blabla.test3; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class Test3Activity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String url ="file:///android_asset/qualibus.swf"; WebView wv=(WebView) findViewById(R.id.webView1); wv.getSettings().setPluginsEnabled(true); wv.loadUrl(url); } }
i can not find wv.getSettings().setPluginsEnabled(true); method... i can only find webView.getSettings().setPluginState(PluginState.ON); method... please help me
The function WebView.getSettings().setPluginsEnabled(); method has been deprecated since API level 9, and was removed in API level 18.
You can use the newer functionWebView.getSettings().setPluginState(WebSettings.PluginState.ON); which was added in API level 8 and was deprecated in API level 18.
According to the WebSettings Documentation API levels beyond 18 will not support plugins; I'm assuming it's because the main plugin to support was flash which adobe is no longer developing for mobile.
Am trying to play local .swf files (kept in asset or sdcard) inside webview. But am not getting any luck...Can anyone guide me the proper way??? I am able to play swf files via url....but getting difficulty in playing local file inside webview
Am using the code as: <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Flash</title> </head> <body> <object width="550" height="400"> <param name="movie" value="circa-med.swf""> <embed src="circa-med.org/circa-med.swf"; width="550" height="400"> </embed> </object> </body> </html> Its working fine...Instead the url I want to use the code as <embed src=\"file:///sdcard/sample.swf\" to take the file from sdcard – Vivek TamrakarMay 24 '11 at 7:39
package webView.video; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.webkit.WebView; public class WebViewActivity extends Activity { private WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate (Bundle savedInstanceState) { super. onCreate (savedInstanceState); setContentView(R.layout.main); // html file with sample swf video in sdcard //swf2.html points to swf in sdcard mWebView = (WebView)findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); mWebView.getSettings().setAllowFileAccess(true); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ System.exit(4); } else { mWebView.loadUrl("file://" + Environment.getExternalStorageDirectory() + "/swf2.html"); } } }
@VENKI did you get answer to your question? I faced the same problem, and in my application also it was showing that blue colored cube with question mark symbol. I managed to solve it. I had flash installed in my device and still I was getting that cube. Let me know if you need the answer. – vaibhavMar 2 '12 at 13:05
Thanks but my doubt is while running swf file in browser (from server) we use these lines: "<param name=\"movie\" value=\"circa-med.swf\"> " + "<embed src=\"circa-med.org/circa-med.swf\" width=\"160\" height=\"180\"> " + "</embed>"+ "</object>" ........But for local file how to give path under<embed> tag – Vivek TamrakarMay 24 '11 at 9:09
Well, the first question is whether you need it to be embedded in a web page at a specific pixel size... if not, the above solution may be more useful. If you do need it embedded, does <param name=\"movie\" value=\"file:///android_asset/YourFile.swf\">... work for assets? If it does, you could probably edit the HTML string programmatically to include the results of "file://" + Environment.getExternalStorageDirectory() + "/YourPath/YourFile.swf" as the embedded file, for files on the SD card. – Sven VikingMay 24 '11 at 9:26
You'd still need to set setAllowFileAccess(true) and add the Permission as mentioned above, of course, for reading from the SD card. – Sven VikingMay 24 '11 at 9:33
Afraid I haven't worked with .3gp files before -- I didn't know the Android WebView even supported them.EDIT: I just did some quick Googling, and from what I can see I'm pretty sure the WebView cannot load .3gp files. – Sven VikingMay 24 '11 at 13:34
The problem is just that the WebView has no height or width. Change the addView line to:linearLayout.addView(webview, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); . I just tried this myself, and it worked fine. – Sven VikingMay 25 '11 at 7:45
import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.webkit.WebView; public class WebViewActivity extends Activity { private WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate (Bundle savedInstanceState) { super. onCreate (savedInstanceState); setContentView(R.layout.main); // html file with sample swf video in sdcard //swf2.html points to swf in sdcard mWebView = (WebView)findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); mWebView.getSettings().setAllowFileAccess(true); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ System.exit(4); } else { mWebView.loadUrl("file://" + Environment.getExternalStorageDirectory() + "/swf2.html"); } } }