【问题标题】:How to play .swf files in Android?如何在 Android 中播放 .swf 文件?
【发布时间】:2016-12-31 15:36:38
【问题描述】:

我通过将 Adob​​e Flash Player apk 从资产复制到 SD 卡并使用 Intent 安装来安装它。即使在那之后,webView 也无法加载 .swf 文件。

我是否应该改用 Adob​​e Flash builder 来开发 Android 应用程序。我的主要要求是从服务器播放 .swf 文件!

这是我的代码。

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flash);

        installFlashPlayer();


//Fake Url
//        String url = "http://www.test.com/test.swf";
//
//        webView = (WebView) findViewById(R.id.webView);
//        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
//        webView.setWebViewClient(new WebViewClient());
//
//        webView.getSettings().setUseWideViewPort(true);
//        webView.getSettings().setLoadWithOverviewMode(true);
//        webView.loadUrl(url);

    }

    void installFlashPlayer(){
        AssetManager assetManager = FlashActivity.this.getAssets();

        InputStream in = null;
        OutputStream out = null;

        try {
            in = assetManager.open("flp.apk");
            out = new FileOutputStream(Environment.getExternalStorageDirectory()  + "/flp.apk");

            byte[] buffer = new byte[1024];

            int read;
            while((read = in.read(buffer)) != -1) {

                out.write(buffer, 0, read);

            }

            in.close();
            in = null;

            out.flush();
            out.close();
            out = null;

            Intent intent = new Intent(Intent.ACTION_VIEW);

            intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/flp.apk")),
                    "application/vnd.android.package-archive");

            startActivity(intent);

        } catch(Exception e) { }
    }

【问题讨论】:

    标签: java android flash adobe


    【解决方案1】:

    您可以使用"GeckoView of Firefox" 我在我的项目中使用了它。

    对播放 swf 文件很有用。

    您还需要在 GeckoView 中设置plugin.state.flash = true;..

    如果你选择使用 GeckoView(如果我没记错的话),你的 apk 会增加 20-25 mb,因为 GeckoView 与 jni 一起使用......

    【讨论】:

    • 我在 GeckoView 库中找不到 plugin.state.flash。我们如何设置它?
    • 抱歉回复晚了,但是你必须像 about:config in firefox 一样设置它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 2012-01-26
    • 2013-04-24
    • 1970-01-01
    • 2021-09-15
    • 2013-07-07
    相关资源
    最近更新 更多