How to Play local swf files in a webview
swf2.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
</head>
<body>
<object width="215" height="140">
<param name="movie" value="choudanse7us.swf">
<embed src="file:///mnt/sdcard/choudanse7us.swf"
width="215" height="140">
</embed>
</object>
</body>
</html>
below is the android code
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");
}
}
}
Play .SWF files from internal storage in android webview in nexus 7 android
I found a workable solution...dont know how feasible it is but this solution works for me
follow this steps..
Step1->Download flash player apk from this
Link to download Flash Player apk
Step2->After downloading go to settings--->security---->Check "Unkown sources option".
Step3->install the apk that you downloaded+
Now your webview code will work and .swf files can be played inside webview
[note-download flashplayer apk for android 4.0 devices for ics and above].
webview cant display swf file (simple code)
All i need is just adding screen.getSettings().setPluginsEnabled(true);
, and the swf file will be shown :D
How to play media files (3GP/swf files) locally inside webview
To play SWF files you have to enable plugins:
_webview.getSettings().setPluginState(PluginState.ON);
and if your .html file uses javascript:
_webview.getSettings().setJavaScriptEnabled(true);
EDIT to answer comment
In your situation you need to use your own webview at the moment links are redirecting to the browser:
_webview.setWebViewClient(new DownloadWebViewClient());
public class DownloadWebViewClient extends WebViewClient{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false; // Allows your webview to handle clicked links
}
}
Load an SWF into a WebView
Figured it out. You have to enable plugins.
webview.getSettings().setPluginsEnabled(true);
loading flash files (.swf) webview in android
I think You should implement setPluginsEnabled method.
example
String url ="file:///android_asset/hoge.swf";
WebView wv=(WebView) findViewById(R.id.WebView01);
wv.getSettings().setPluginsEnabled(true);
wv.loadUrl(url);
Related Topics
Custom Format Edit Text Input Android to Accept Credit Card Number
Avoiding Content Type Issues When Downloading a File via Browser on Android
Androidstudio - Module Dependencies in Gradle
How to Iterate Through a View's Elements
Where Does Android View.Scrollto(X, Y) Scroll To
How to Use the Android Accelerometer
Phonegap Plugin:How to Convert Base64 String to a Png Image in Android
Create Custom Big Notifications
Android Spinner with Different Layouts for "Drop Down State" and "Closed State"
Voice Recognition Stops Listening After a Few Seconds
Displaying Yuv Image in Android
Dynamic Resource Loading Android
Error:(9, 5) Error: Resource Android:Attr/Dialogcornerradius Not Found
How to Get Ndk-Gdb Working on Android
Change Viewpager Animation Duration When Sliding Programmatically