2017년 3월 27일 월요일

Countdown Timer


Is iit possibile to add an hour to countdown Timer. Because I need to play the lecture and it takes around two hours and half.


--
sure, that's possible


first you should understand, how that example is working
and after that, it should be no problem for you to add a global variable intHoursLeft...
remember: and hour has 60 minutes...
see also these general tips 

-- 
I tried so many times but I couldn't understand the how is working.Please help me.



-- 
how many milliseconds are there in 1 hour?



-- 
alternatively now you also can use the new clock methods
DurationToHours
DurationToMinutes
DurationToSeconds

-- 
I tried again but it doesn't work. It is very difficult.

countdowntimer.png 표시 중

-- 
I tried again but the timer it doesn't move.


countdowntimer.png 표시 중

-- 
the second screenshot looks better
after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

-- 
I tried to do what have said, but unfortunately, it doesn't work



-- 
If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...


To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

--
Thank you Taifun for your help.
Please tell me what can I do. 


 -- 
this was the correct calculation of the hours



after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

-- 
Please see attached image.
I really appreciate of you support and help.



-- 
I think, it's important to understand, what you are doing...
therefore let's take an example and let's calculate it manually

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours

then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

-- 
I have been trying to calculate this equations you had mentioned since yesterday. Now,I understand more than before, but please learn me more.

countdowntimer.png 표시 중

-- 
Can you check this calculation if it is more correct?



-- 

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds


after calculation of the hours, where are the remaining milliseconds now in your blocks?

also you forgot to answer these questions
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds




also use Do it to debug your blocks, see tip 4 here 



-- 
Sorry, I can't find the remaining milliseconds in block. but what I know that it is 1842000


-- 
as already said
after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc


-- 
Please check the calculation



-- 
it is YOU who should check the calculation...
and the tool to use is as already said Do it, see tip 4 here
Top 5 Tips: How to learn App Inventor



why do you use the LeadingZeros procedure for the remaining milliseconds?



let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds


you still forgot to answer these questions

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

what about providing some answers now?

1842000 milliseconds
how many minutes do you get? how many seconds do you get?

protip: take a look at the original solution here https://puravidaapps.com/countdown.php

-- 
1842000 / 60000  = 30 minutes


-- 
Yes, I have got it now. Thank you Taifun.
But the problem is that the timer doesn't start countdown until become less than one hour.


-- 
I think, you have to subtract additionally the hours




use Do it to debug your blocks

--
Yes, you are right.
Now is working.
Thank you so much Taifun for your learning me.
I want to know is there an example for count-up instead?






-- 

 is there an example for count-up instead?
I don't know
probably you can find an example after doing a search in the forum?

also what about just trying to build it yourself?
you learned how to count down... to count up should be similar...


-- 
Can you please give me a hint how to start and I will complete the calculation.

-- 
I need your help to tell me what can I do to start the calculation in correct way.



-- 
sorry, I do not have time currently, you might want to try something yourself or someone else might chime in

-- 
What is the difference between count-up and count-down? Just reverse the numbers and get the difference in time. You know already how to calculate that difference.

-- 
Thank you Ghica,
I will be happy if you give me an example in reverse of this example for countdown timer :
let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

-- 
this thread was about count down timer and has been answered
your thread about count up timer is here: Count-up Timer

-- 

댓글 없음:

댓글 쓰기