here issue seekbar
updation media player seekbar
not working media player .. when user touch on seekbar
takes backward user touched ... here code snippet .. know issue behind ... please t
seekbar = (seekbar) findviewbyid(r.id.seekbar); seekbar.setonclicklistener(this); seekbar.setonseekbarchangelistener(this); @override public void onprogresschanged(seekbar arg0, int arg1, boolean arg2) { // todo auto-generated method stub } @override public void onstarttrackingtouch(seekbar arg0) { mhandler.removecallbacks(mupdatetimetask); } @override public void onstoptrackingtouch(seekbar arg0) { mhandler.removecallbacks(mupdatetimetask); int totalduration = mp.getduration(); int currentposition = utils.progresstotimer(seekbar.getprogress(), totalduration); // forward or backward seconds mp.seekto(currentposition); // update timer progress again updateprogressbar(); }
here utilities class
public class utilities { public string millisecondstotimer(long milliseconds){ string finaltimerstring = ""; string secondsstring = ""; // convert total duration time int hours = (int)( milliseconds / (1000*60*60)); int minutes = (int)(milliseconds % (1000*60*60)) / (1000*60); int seconds = (int) ((milliseconds % (1000*60*60)) % (1000*60) / 1000); // add hours if there if(hours > 0){ finaltimerstring = hours + ":"; } // prepending 0 seconds if 1 digit if(seconds < 10){ secondsstring = "0" + seconds; }else{ secondsstring = "" + seconds;} finaltimerstring = finaltimerstring + minutes + ":" + secondsstring; // return timer string return finaltimerstring; } public int getprogresspercentage(long currentduration, long totalduration){ double percentage = (double) 0; long currentseconds = (int) (currentduration / 1000); long totalseconds = (int) (totalduration / 1000); // calculating percentage percentage =(((double)currentseconds)/totalseconds)*100; // return percentage return percentage.intvalue(); } public int progresstotimer(int progress, int totalduration) { int currentduration = 0; totalduration = (int) (totalduration / 1000); currentduration = (int) ((((double)progress) / 100) * totalduration); // return current duration in milliseconds return currentduration * 1000; }
}
this entire code seekbar
not being updated properly
Comments
Post a Comment