将swf文件作为原始文件嵌入android中

时间:2010-11-22 06:07:02

标签: android flash

嘿,有人可以告诉我如何嵌入像这样的文件 http://circa-med.org/circa-med.swf

在android中播放。我是初学者。所以甚至不知道如何播放视频文件。 如果你是特定于Android的话会有所帮助。

3 个答案:

答案 0 :(得分:0)

您可以使用webview进行操作并在没有互联网连接的情况下运行它。另请注意,swf fle需要手机上的flash播放器。由于模拟器不支持flash,因此下面的代码将有一个空白方块。

webview = (WebView)findViewById(R.id.GameWebView);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setPluginsEnabled(true);
settings.setAppCacheEnabled(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
gamePlay="<html><head><title></title></head>" +
    "<body>" +
    "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0?' " +
    "width='320' height='240'>" +
    "<param name='movie' value='"+ Path +"'" +
    "<embed src='file:///android_asset/games/tokudu.swf' " +
    "pluginspage='http://www.adobe.com/products/flashplayer/'" + 
    "type='application/x-shockwave-flash' width='320' height='240'>" +
    "</embed>" +
    "</object>" +
    "</body></html>";
    webview.loadData(gamePlay, "text/html" ,"utf-8");

答案 1 :(得分:0)

只需将swf文件放在assets文件夹中即可。休息不算什么。 如果以下代码不起作用。这意味着您使用的设备存在一些问题。由于此代码适用于测试的spice选项卡而不适用于AROMA。 **

public class flashapp 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);

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

        String html = "<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///android_asset/flash_file.swf\"> <embed src=\"file:///android_asset/flash_file.swf\" width=\"550\" height=\"400\"> </embed> </object>";
        String mimeType = "text/html";
        String encoding = "utf-8";

        mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
    }
}

答案 2 :(得分:-1)

将它放在网页上应该不会太难。使用像pastehtml这样的免费服务来托管代码。

<object width="320" height="240">
<param name="movie" value="http://circa-med.org/circa-med.swf">
<embed src="http://circa-med.org/circa-med.swf" width="320" height="240"></embed>
</object>

以下是一个实例:http://pastehtml.com/view/1ct84ug.html

顺便说一下,你列出的那个例子需要很长时间才能加载。考虑到它是移动设备,这可能是个问题。