java - Issue in changing the visiblity of buttons inside OnClickListener -
below code playing audio in project.when click on play button changes pause button , playing audio through init() method inside application class.the issue facing after clicking on play button takes few seconds(5-10 seconds) after play button changes pause.but should change pause button first statement inside onclick() holder.pause.setvisibility(view.visible);
. if comment out init method call line projectapplication.getinstance().init(mctxt, lmoment.getprojectmedialoc(), holder.lvisualizerview, laudioprogressbar,holder.image,holder.image2);
changes pause button init method required playing audio.if use postdelayed() method , call init() method after 2 seconds works expected .but fail understand why init() method creating problem in changing visiblity of play , pause buttons init method() called after changing visiblity.
holder.play.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { holder.pause.setvisibility(view.visible); holder.play.setvisibility(view.invisible); projectapplication.getinstance().init(mctxt, lmoment.getprojectmedialoc(), holder.lvisualizerview, laudioprogressbar,holder.play,holder.pause); notifydatasetchanged(); } });
projectapplication.java
public void init(context mctxt,string aaudiourl, final visualizerview mvisulizerview,final progressbar laudioprogressbar,final imageview play,final imageview pause ) { laudioprogressbar.setvisibility(view.visible); mprojectplayer= mediaplayer.create(mctxt, uri.parse(aaudiourl)); mprojectplayer.setlooping(false); mprojectplayer.setonpreparedlistener(new mediaplayer.onpreparedlistener() { @override public void onprepared(mediaplayer mediaplayer) { log.e("msg","start"); mprojectplayer.start(); mprogressbar.setvisibility(view.gone); laudioprogressbar.setvisibility(view.invisible); mprojectplayer.setoncompletionlistener(new mediaplayer.oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { play.setvisibility(view.visible); pause.setvisibility(view.invisible); mvisulizerview.setvisibility(view.invisible); projectapplication.getinstance().cleanup(mvisulizerview); homefragment.projectlistadapter.notifydatasetchanged(); } }); } });
Comments
Post a Comment