android - How to play, pause and stop a song with only one button? -
i have tried make application in android play, pause , stop song 1 button only.
can show me how can make application?
final button bplay = (button)findviewbyid(r.id.bplay); mediaplayer song1 = mediaplayer.create(tutorialfour.this, r.raw.fluet); button bstop = (button)findviewbyid(r.id.bstop); bplay.setwidth(10); song1.setoncompletionlistener(new oncompletionlistener() { public void oncompletion(mediaplayer mp) { bplay.settext("play"); } }); bplay.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { // todo auto-generated method stub b=true; if(bplay.gettext().equals("play") && b==true) { song1.start(); bplay.settext("pause"); b=false; } else if(bplay.gettext().equals("pause")) { x=song1.getcurrentposition(); song1.pause(); bplay.settext("resume"); log.v("log",""+x); b=false; } else if(bplay.gettext().equals("resume") && b==true) { song1.seekto(x); song1.start(); bplay.settext("pause"); b=false; } } });
Comments
Post a Comment