android - How to play audio and wait to finish to countinue to play again? -
how play audio , wait finish countinue play again?? . in can play many time :d
ivselect.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub // toast.maketext(context, "hello", 1000).show(); mmediaplayer = mediaplayer.create(context, sound); if (mmediaplayer.isplaying() == false) { mmediaplayer.start(); mmediaplayer .setoncompletionlistener(new oncompletionlistener() { public void oncompletion(mediaplayer mp) { mp.release(); }; }); } } });
the code working fine every button click. if wish audio repeated automatically, use
mmediaplayer.setlooping(true);
if wish when ist sound played then, second 1 should start on button click, try disabling ur button click while first sound playing , enable click oncompletelistener... thing this:
ivselect.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub // toast.maketext(context, "hello", 1000).show(); mmediaplayer = mediaplayer.create(context, sound); ivselect.setclickable(false); //disabling button click mmediaplayer.start(); }
enable click on audio completion
mmediaplayer.setoncompletionlistener(new oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { ivselect.setclickable(true); } });
Comments
Post a Comment