Count up instead of down?
2 views (last 30 days)
Show older comments
Hello All! I have this snippet ofcode:
r=get(mp.currentMedia,'duration');
remaint=r-currpos1;
set(handles.edit2,'String',remaint);
Basically, it gets the "duration" of the currently selected video in a GUIDE GUI in seconds, then -1 it by 1 and sends the value to an edittext.
Problem is it counts down 40, 39, 38... instead of up. I'm trying to figure out a way to modify this code so it counts from 0 to "duration"
Thanks!
0 Comments
Accepted Answer
Oleg Komarov
on 4 Aug 2011
If remaint counts as 40, 39, 38... then simply currpos1 will count 0, 1, 2...
9 Comments
Oleg Komarov
on 4 Aug 2011
Ehm...I wanted to ask if "are you sure you want to count it up since ..."
More Answers (4)
Image Analyst
on 4 Aug 2011
I don't know what this means "...then -1 it by 1 ..." If r is the total time of the video, and currpos1 is the elapsed time, then remaint is the remaining time, and of course that will count down as you observed. The longer it plays, the less time there is left. If you want it to show elapsed time instead of remaining time, just send currpos1 to the static text label instead of remaint. The elasped time will, of course, count up.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!