如何在 webview 中播放本地 swf 文件 [英] How to Play local swf files in a webview

查看:26
本文介绍了如何在 webview 中播放本地 swf 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 webview 中播放本地 .swf 文件(保存在资产或 SD 卡中).但是我运气不好……谁能指导我正确的方法???我可以通过 url 播放 swf 文件....但是在 webview 中播放本地文件有困难

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

推荐答案

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>

下面是安卓代码

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");
         }

     }
}

这篇关于如何在 webview 中播放本地 swf 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆