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);
}
}
@ ud_an我怎麼能嵌入plz告訴我......用一個例子..... –
@srinivasaraghavanramji編輯hv一下 –