首先嚐試做耐心操作我是全新的Android和提問 我編寫了一個代碼來播放SD卡上某些文件的某些歌曲。但是當我在AVD上運行這個項目時什麼也沒有發生。這裏是我播放這些mp3歌曲的代碼我想同時播放SD卡上的某個文件的某些mp3歌曲
private Button Play,Exit;
private static final String MEDIA_PATH = new String("/sdcard/Arabic/");
private MediaPlayer player;
private String a,z,startstr,endstr,namestr,soranamestr,firstayaname;
private int beginning,ending;
Thread thread;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Surat=(EditText)findViewById(R.id.Surat);
Start=(EditText)findViewById(R.id.Start);
End=(EditText)findViewById(R.id.End);
Play = (Button)findViewById(R.id.playButton);
Play.setOnClickListener(playListener);
Exit = (Button)findViewById(R.id.exitButton);
Exit.setOnClickListener(exitListener);
}
private View.OnClickListener exitListener = new View.OnClickListener() {
public void onClick(View v) {
try {
player.release();
finish();
System.exit(0);
}
catch (Exception e) {
e.printStackTrace();
}
}
};
private View.OnClickListener playListener = new View.OnClickListener()
{
public void onClick(View v) {
play();
}
};
private void play()
{
try {
player.reset();
player.setDataSource(MEDIA_PATH);
player.prepare();
player.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
你可以發揮它在設備 – Chaithanya 2012-03-18 13:16:31
其實我還沒有android設備 – dio 2012-03-18 13:35:41