2011-07-15 149 views
0

我的Android應用程序需要播放.swf文件,這些文件只有聲音。是否有插件或其他內容,以便我可以正常播放它們?謝謝。播放.swf聲音文件?

+0

http://stackoverflow.com/questions/1887758/playing-a-flash-file- in-android – marto

回答

0

這裏是完美的解決方案::

package com.adySol; 

import android.app.Activity; 
import android.os.Bundle; 
import android.webkit.WebSettings.PluginState; 
import android.webkit.WebView; 

public class adySol extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 



    String url ="file:///android_asset/mulberrybush.swf"; 
    // String url ="http://www.bing.com/"; 
WebView wv=(WebView) findViewById(R.id.webView1); 
wv.getSettings().setJavaScriptEnabled(true); 
    wv.getSettings().setPluginState(PluginState.ON); 
    wv.getSettings().setAllowFileAccess(true); 
wv.loadUrl(url); 

} 
} 

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@android:color/white" 
> 
<WebView android:id="@+id/webView1" android:layout_width="match_parent" android:layout_height="match_parent"></WebView> 

</LinearLayout> 
+0

感謝您的回答,但它在MediaPlayer中播放普通.mp3文件時工作正常,CPU負載爲〜0%。儘管如此,使用它來播放.swf使用〜6%的cpu。這是爲什麼?另一個問題:這也適用於2.1之前的手機(1.5/1.6)嗎? – Omar

+0

這是工作只有2.2和更高的版本。 –

+0

有什麼可以讓它在舊設備上工作嗎? – Omar