有什么办法可以将swf文件加载到andoird中 [英] Is there any way to load swf file into andoird
问题描述
我正在将SWF文件加载到Andriod中.
I am loading SWF file into Andriod.
我正在尝试使用webview,但无法加载插件出现错误
I am trying with webview, but there is an error couldn't load plug-in
String text="<html>\n" +
" <head>\n" +
" <meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\" />\n" +
" </head>\n" +
" <body>\n" +
"<h1>jvjhvjhv</h1>\n"+
" <object width=\"215\" height=\"140\">\n" +
" <param name=\"movie\" value=\"airplane.swf\">\n" +
" <embed src=\"file:///android_asset/airplane.swf\"\n" +
" width=\"215\" height=\"140\">\n" +
" </embed>\n" +
" </object>\n" +
" </body>\n" +
"</html>";
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView)findViewById(R.id.web);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setAllowFileAccess(true);
//mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Mobile; Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0");
mWebView.loadData(text,"text/html","utf-8");
}
任何人都可以给我一个在Android中加载SWF文件的答案吗?
Can anyone give me an answer to load SWF file in android?
谢谢
推荐答案
我正在将SWF文件加载到Android中.
我正在尝试使用WebView,但是出现错误消息"Could not load plug-in"
.
谁能给我一个在Android中加载SWF文件的答案吗?"
"I am loading SWF file into Android.
I am trying with WebView, but there is an error saying"Could not load plug-in"
.
Can anyone give me an answer to load SWF file in Android?"
您可以尝试: SWF 2 JS .您要保存此文件 swf2js.js 并在您自己的HTML代码中使用.
成功将取决于您的SWF文件内容. SWF2JS
支持Flash动画和AS2代码.
You could try: SWF 2 JS. You want to save this file swf2js.js and use in your own HTML code.
Success will depend on your SWF file content. SWF2JS
supports Flash animations and AS2 code.
-
我尚未在Android WebView(带有动态HTML字符串)中对此进行过测试,但是在PC上,它希望从在线或通过设备的localhost服务器访问文件.
I've not tested this in an Android WebView (with dynamic HTML string) but on PC it expects files to be accessed from either online or else via device's localhost server.
如果加载动画时有任何问题.尝试使用以下位置的文件:https://
而不是file:///
.
If any problems loading an animation. Try using files from location: https://
not file:///
.
演示(测试它们是否可以在您的Android设备上显示):
Demos (test if these can display on your Android device) :
1)Flash图形: https://vcone.github.io/public/flash/demo1.html
1) Flash graphics: https://vcone.github.io/public/flash/demo1.html
2)使用代码的游戏: https://vcone.github.io/public/flash/demo2.html
2) Game with code: https://vcone.github.io/public/flash/demo2.html
如果上述SWF文件可在Android上运行,则可以尝试以下嵌入代码:
If the above SWF files work on Android, then you can try some embed code like below:
<head>
<script type="text/javascript" src="file:///android_asset/swf2js.js"></script>
</head>
<body>
ADROID TEST: Displaying SWF with JavaScript and HTML5 Canvas... <br><br>
<div id="myFlashDiv" style="width:800px; height:800px;"></div>
<script type="text/javascript">
var mySWF = swf2js;
mySWF.load('file:///android_asset/airplane.swf', {"tagId": "myFlashDiv"});
</script>
</body>
这篇关于有什么办法可以将swf文件加载到andoird中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!