我怎样才能使用的WebView和访问从我的资产目录中的文件播放SWF文件? [英] How can I play a swf file using WebView and accessing the file from my assets directory?

查看:148
本文介绍了我怎样才能使用的WebView和访问从我的资产目录中的文件播放SWF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid和Flash开发。我用闪存来实现节拍器部分创造了我的吉他应用程序的节拍器。我已经有吉他和我节拍器动画创建一个单独的Flash文件中的工作项目。

I am new to both android and flash development. I am creating a metronome for my guitar app by using flash to implement the metronome portion. I already have a working project for the guitar and a separate flash file that I created for the metronome animation.

我已经做了很多本网站的研究和不能似乎找到任何工作,我的code如下。我只是制作新手的错误或者是有更大的东西,我可以尝试,这将更好地为我。

I have done a lot of research on this website and cant seem to find anything that is working, my code is below. Am I just making a rookie mistake or is there something bigger that I can try that will work better for me.

我的目标是有活性的访问Metronome.swf文件,并发挥它就像由快速生成的.apk文件一样。

My goal is to have the activity access the Metronome.swf file and play it just as the .apk generated by flash does.

下面是我的metronome.xml文件:

Here is my metronome.xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   />
</LinearLayout>

这是我MetronomeActivity.java文件:

And this is my MetronomeActivity.java file:

package itcs4155.group4.guitarTeacher;


import android.os.Bundle;
import android.webkit.WebView;

public class MetronomeActivity extends BaseActivity {
   private WebView mWebView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.metronome);


        mWebView = (WebView)findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setPluginsEnabled(true);


        String html = "<object width=\"768\" height=\"1024\"> <param name=\"movie\" value=\"file:///android_asset/Metronome.swf\"> <embed src=\"file:///android_asset/Metronome.swf\" width=\"768\" height=\"1024\"> </embed> </object>";
        String mimeType = "text/html";
        String encoding = "utf-8";
        mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
    }
}

感谢提前任何帮助!

Thanks for any help in advance!

推荐答案

有些时候,它可能发生在swf文件获得通过,不显示Web视图加载。

Some times it may happen that the swf file get loaded on the web view by is not displayed.

尝试添加机器人:机器人:在hardwareAccelerated =真正的您的清单文件

Try adding android:android:hardwareAccelerated="true" in your manifest file.

<application android:hardwareAccelerated="true">
        <activity ... />
        <activity android:hardwareAccelerated="true" />
    </application>

这可能有助于...

It might help...

这篇关于我怎样才能使用的WebView和访问从我的资产目录中的文件播放SWF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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