public class MusicPlayer extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
// Find the Button from the xml-file.
Button cmd_play = (Button)this.findViewById(R.id.cmd_play);
cmd_play.setOnClickListener(new OnClickListener(){
//@Override
public void onClick(View arg0) {
// res/raw Æú´õ³»¿¡ sound_file ÆÄÀÏÀ» Ãß°¡ÇسõÀ½.
MediaPlayer mp = MediaPlayer.create(MusicPlayer.this,
R.raw.sound_file);
mp.prepare();
mp.start();
// i.e. react on the end of the music-file:
mp.setOnCompletionListener(new OnCompletionListener(){
//@Override
public void onCompletion(MediaPlayer arg0) {
// File has ended !!! Wink
}
});
}
});
}
}