2011-11-14 153 views
0

我用來播放網站上的音樂。我用來加載HTML頁面和Flash播放器。但是當我按播放按鈕它突然改變暫停按鈕在設備爲什麼我必須使用任何緩衝區方法流plz告訴我,誰會出錯.....我使用galaxys.and代碼是...... 。?Flash播放器不能播放android中的音樂

import java.io.IOException; 

    import android.app.Activity; 
    import android.media.AudioManager; 
    import android.media.MediaPlayer; 
    import android.os.Bundle; 
    import android.util.Log; 
    import android.view.View; 
    import android.webkit.WebSettings; 
    import android.webkit.WebView; 
    import android.widget.Button; 

public class Mymediaplayer extends Activity { 
private WebView wv; 
Button b1; 
MediaPlayer player; 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    b1=(Button)findViewById(R.id.button1); 
b1.setOnClickListener(new View.OnClickListener() { 

@Override 
public void onClick(View v) { 
    // TODO Auto-generated method stub 
// playvideofromresource(); 
// playvideofromsdcard(); 

    setupWebView(); 
    //playaudiofromremorturl(); 

    } 
    }); 
     } 
    public void setupWebView(){ 
    wv = (WebView) findViewById(R.id.web_view); 
    wv.setVisibility(View.VISIBLE); 
    if(wv != null){ 
     wv.getSettings().setJavaScriptEnabled(true); 
     wv.getSettings().setPluginState(WebSettings.PluginState.ON); 
     wv.loadUrl("http://media.radiosai.org/www/Afristream.html"); 

    } 
    } 
    void playaudiofromremorturl() 
    { 
player=new MediaPlayer(); 
String urlstring="http://media.radiosai.org/www/Afristream.html"; 
player.setAudioStreamType(AudioManager.STREAM_MUSIC); 
try 
{ 
     player.reset(); 
    player.setDataSource(urlstring); 
    player.prepareAsync(); 
    player.start(); 
} 
catch (IOException e) { 
    e.printStackTrace(); 
    // TODO: handle exception 
} 
player.setLooping(true); 

} 
    } 

回答

0

嘗試使用swfObject在html頁面中嵌入您的Flash內容,然後在webview中加載該html頁面。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 
<body bgcolor="#000000" style="margin: 0; padding: 0"> 
<table width=800px height=600px border=1> 
    <tr> 
     <td> 
      <div id="moviename"></div> 
     </td> 
    </tr> 
</table> 

<script type="text/javascript" src="swfobject.js"></script> 
<script type="text/javascript"> 
swfobject.embedSWF("main.swf", "moviename", "1024", "600", "9.0.0"); 
</script> 
</body> 
</html> 
+0

@ ud_an我怎麼能嵌入plz告訴我......用一個例子..... –

+0

@srinivasaraghavanramji編輯hv一下 –