0

Iam looking for playing media files inside webview Can you please help me out ..what iam missing..I loaded webview as : _webview.loadUrl("file:///android_asset/3gp.html"); and the code inside my html file is as:

<body>
<object width="550" height="400">
<param name="movie" value="sample.3gp">
<embed src="file:///android_asset/sample.3gp" width="550" height="400">
</embed>
</object>
</body>.

Iam not getting the output. Please hellp me out ..Thanks in advance

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
Vivek Tamrakar
  • 271
  • 3
  • 4
  • 15

1 Answers1

2

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                
    }
 }
Blundell
  • 75,855
  • 30
  • 208
  • 233
  • 1
    I kept sample.swf file in asset folder and am trying to run that file inside browser but am gettin blank screen..Can anyone help me. I have a code like: _linearLayout = new LinearLayout(this); _webview = new WebView(this); _linearLayout.addView(_webview); setContentView(_linearLayout); _webview.getSettings().setJavaScriptEnabled(true); _webview.getSettings().setPluginsEnabled(true); _webview.getSettings().setAllowFileAccess(true); String url ="file:///android_asset/sample.swf"; _webview.loadUrl(url); – Vivek Tamrakar May 25 '11 at 06:00