[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Progress control

I need to create a progress bar control while playing media.I need an algorithm to construct the progress control.

MediaTotalPlayTime = 32000;

suppose width of the progress bar rectangle,
dx = 60.

I have to fill the rectangle every 1000 sec. So how much of the rectangle shd be filled every 1000th time.

Hope I have made myself clear!!!

Thanks.
0
abi_a
Asked:
abi_a
  • 2
1 Solution
 
david_barkerCommented:
time : the current value
32000 : the max value
60 : the max size of the progress bar

xpos = (time * 60) / 32000

xpos is the current position versus time.

Is that clear enough ?
0
 
kumvjuecCommented:
it's trickier. you should keep track of how much time you have played and how much rectangle you have already filled.
suppose that t is the time already played and x units of rectangle already filled. Then now you have to fill

(60-x)*1000/(32000-t)

This will guarantee that your progress bar is completely filled when you have played for the full time. You start with t=0 and x=0
0
 
kumvjuecCommented:
This much for every 1000 seconds. But if you want to fill every 1000th time, then of course don't multiply by 1000 above.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now