Reputation: 11
I'm creating an app for android using mediaplayer. I just created the "play", and the pause button. Here is my code:
player = MediaPlayer.create(this, R.raw.iinfancia);
try {
player.prepare();
}
catch (Exception e) {
}
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
player.start();
}
});
pausar.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
player.pause();
}
});
Now I want to know, how do I make the "stop" button, because when I do this:
stop.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
player.stop();
}
});
The song stop, but when I click at "Play" again, the sound doesn't start.
Upvotes: 0
Views: 189
Reputation: 93542
Use player.pause() instead. Just like a cd player, stop ends playback permanently, pause lets you restart from that point.
Upvotes: 2