【问题标题】:Embedding swf file as raw files in android在android中嵌入swf文件作为原始文件
【发布时间】:2011-05-13 16:00:12
【问题描述】:

嘿,谁能告诉我如何嵌入这样的文件 http://circa-med.org/circa-med.swf

并在 android 中播放。我是初学者。所以甚至不知道如何播放视频文件。 如果您是特定于 android 的,这将有所帮助。

【问题讨论】:

    标签: android flash


    【解决方案1】:

    您可以使用 webview 来完成它并在没有互联网连接的情况下运行它。另请注意,swf 文件需要手机上的 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");
    

    【讨论】:

    • 编辑:gamePlay=" " + "" + "" + "adobe.com/products/flashplayer'" + "type='application/x-shockwave-flash' width='320' height='240'>" + "" + "" + ""; webview.loadData(gamePlay, "text/html","utf-8");我无法在答案部分添加此 sn-p,因此请在此处添加。
    【解决方案2】:

    只需将 swf 文件放在 assets 文件夹中即可。休息什么都不是。 如果以下代码不起作用。这意味着您使用的设备有问题。由于此代码适用于经过测试的香料标签而不是 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, "");
        }
    }
    

    【讨论】:

      【解决方案3】:

      将它放在网页上应该不会太难。使用 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

      顺便说一句,您列出的示例需要很长时间才能加载。考虑到它是移动设备,这可能是问题所在。

      【讨论】:

      • 是否可以将 swf 文件嵌入 apk 并使其在没有任何互联网连接的情况下工作?
      猜你喜欢
      • 2012-08-15
      • 2012-04-25
      • 2012-10-23
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 2010-09-13
      相关资源
      最近更新 更多