我在eclipse中創建了一個應用程序來播放和停止mp3文件。一切都很好,除了當我播放音頻文件,並停止它,我想重播它,播放btn不會wort!我想知道有人能幫助我嗎?提前致謝。 這裏談到的代碼:如何在Android應用程序中播放和停止mp3文件
package ir.polyglotcenter.childrenmostfrequentwords;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Related to the media player
final MediaPlayer myMediaPlayer = MediaPlayer.create(Main.this, R.raw.audio);
//Button related to play btn
Button myButtonOne = (Button) findViewById(R.id.btn_audio);
myButtonOne.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myMediaPlayer.start();
}
});
//Button related to stop btn
Button myButtonTwo = (Button) findViewById(R.id.btn_stop);
myButtonTwo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myMediaPlayer.stop();
}
});
}
}
,爲什麼你有在MediaPlayer決賽? – 2013-03-11 18:52:32
導致編輯要我這樣做 – 2013-03-11 18:59:07