2017년 3월 26일 일요일

Count-up Timer


Is there an example for count-up Timer instead of countdown Timer.  








--
As Taifun said in your previous question, a count up Timer is almost identical to a count down timer.  Instead of counting down from a positive number and subtracting one each second you start counting from 0 and add one.

You should take your existing code for countdown and make a few small changes.

 Isn't it time that you read the Inventor's Guide here http://www.appinventor.org/book2  and reproduce the example code  and start doing some tutorials?  Learning to program is a matter of doing a little reading then experimenting, changing things and seeing what happens.   If you save a copy of your Project with a different name or save an aia of the working code you can not break anything.  

Something like the code below should work.   It is simpler than the code shown at puravidaapps, all it does is count UP.    You need a Button, a Label and a Clock with the interval set to 1000 ms (1 second).

With a small modification, the example code can also count down.    There is no alarm, no code to prevent the app from going to sleep, just the basics.

--
I need an count-up timer which be able to use a slider and a player with it and make that timer start from any position. 

--
If a count up timer means that I want to know what the date and time is after so many milliseconds from now, then this is not an easy question. Like, tonight at 02:00 a.m. summer time will start here, so 7 hours from now, (21:35) is not 04:35 but 05:35 a.m.
See also this thread: https://groups.google.com/forum/#!msg/mitappinventortest/Z6ATYVSFaEA/0REDZ-5nHAAJ

--
Is it possible to make it only for HH:MM:SS?
Please check the blocks


--
Probably yes.
But what is the purpose of this calculation? What do you want to do with it?
Did you test your blocks? What was the result? If it was what you expect, fine. If not, what was wrong?

I am not here as a teacher, checking assignments. My goal is to help people to find answers themselves, which is much more gratifying for both of us.

--
It works but it gives result very slowly. I made it just for getting more experience. 


I need an count-up timer which be able to use a slider and a player of Mp3 with it and make that timer start from any position.

--
There is no problem with that way. But I want to make it with reverse way.

--
You Did not answer my questions, therefore I am not able to answer yours.

--
Actually, I need to make it count-up instead of count-down because I want to start clock with Mp3 sound and all of people want to know in which time they are for example they want to 2 minutes back to listen again what is said.

--
Here is a useful extension to your purpose. 
https://puravidaapps.com/player.php

You may want to use "CurrentPosition", "Duration" and "StartAtPosition".

--
This way is not the thing I want.  I want to know how to build count - up clock.

--

Have you tried this? It is doing exactly what you have asked.
--
No, I didn't try it. Can you please send the aia. please if it is allowed.

--
@zac It is really admirable that you come up with code examples as answers to problems, but the problem with software development is not only how to code something but also what. And that is not clear at all in this case. Therefore you do not know which problem your code is solving, certainly not if it is solving osama's problem.
@osama
My definitition of count down is that you want to calculate the time between now and some time in the future, for example how much time is left befor the new year starts. Apparently that is not what you want.
A definition of count-up could be that you want to know what the date-hour-minutes-seconds is after a fixed duration from now. This is a difficult problem to solve in general, but App Inventor has easy blocks to do that: call Clock1 Add duration, for example. But I am pretty sure that this is not what you want either.

What it is -maybe- that you want, is when someone is listening to an .mp3, that he/she can see how much time has passed since he/she started playing the .mp3.
If yes, then you can calculate this the same way as a count-up, you just use the call Clock1.Duration (start, end) block.So, please show a design of what you want. Try some blocks also to solve your problem and then describe exactly what happens differently from what you think it should be. If tyou do not do that, we will keep shooting in the dark, while you will never be able to learn something and solve your own problems.

--
Yes what I want exactly, is when someone is listening to an .mp3, that he/she can see how much time has passed since he/she started playing the .mp3. But how can I do that. IT IS REALLY DEFFICULT FOR ME TO DO THAT:)

--
Post a simple aia, then I can add this number (or maybe Zac). Have patience, it is national holiday here tomorrow and it is too late now.
--
@Ghica Thank you for the feedback. I put the example from what I understood form @osama. 

@osama I'm not good at explain in words so look at my attachments and see if that similar to what you want. If so, let me know and I'll try to explain the logic of my blocks.




--
Thank you so much Ghica and Zac. This is exactly what I am looking for. Also I had have two slides. But now, One slide is more enough.
You are a very professional Programmer in Android application. Now, I need  only to add an hour. Is it possible? Because the sound is more than two hours.

--
Unfortunately this does not work right. You really need two sliders and also you should not use Pause, because of a bug in app inventor.
Read again your other thread: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/mitappinventortest/9UQ2QLO2c9E/G26eF2oYGQAJ

--
@Ghica: the pause issue in the Player extension has been fixed meanwhile, see also https://puravidaapps.com/player.php

--
Yes you are right Ghica I have problem after I click pause I can't move the slide but before yes. However, it doesn't matter  because after click pause and then play it continue from the same position. The main problem Now is, I need  only to add an hour. Is it possible? Because the sound Mp3 has  more than two hours. Please help me.

--
@Taifun: Thanks! good to know!

@Osama: To fix the pause bug, download the Player extension again. Load it using a new name. Then, change all the references to the old Player extions to the new Player extension. Finally remove the old player extension.
To add the hour: change the pattern to "hh:mm:ss" (it occurs twice).
--
@Ghica: to upgrade an extension, simply import the new version and it will upgrade automatically... it's that simple...

--
@Taifun Oh! I did not know that. I thought that it was still the show stopper for releasing new extensions from MIT itself. Thanks!

--
I have already added hh:mm:ss but it seems that show 3;00;00 when start playing and after completing one hour it change to 4:00:00 it means that add one hour to the three.

--
You must have done something else wrong. 

--
Please see attached.


--
The problem must be in the part you are not showing. If your time starts with 3:00:00, then the initial calculation must be wrong.

--
I am sorry Ghica.
What can I do to fix the problem.

--
Post an .aia

--
Please see attached aia.
Thank you so much Ghica for your usual kindness and help.
I have tested the extension and it works brightly.
Thank you a lot Taifun and Ghica


--


The problem with the hours is this: the duration is formatted as a date-time starting at Januari 1st 1970, taking into account the timezone you are in.
This means, if you are looking at minutes and seconds only, you will not see it, but in my timezone duration 0 is formatted as 01:00:00 and in yours 03:00:00
It is not easily solved by adjusting the timezone, therefore I made a procedure for you to solve it. Look at the blocks attached. For your convenience there is also an .aia
(I did not have the patience to wait for an hour, but I am pretty sure it works).

--
Actually, I am sorry to tell you that I have tested the aia you had sent it many times waiting hour to come but it hasn't come at all.

--
It seems I left some test values in. Now a made a proper calculation, not using the clock. Getting tired I suppose.

--
Now I can sleep in a very deep after you have solve my problem.
Good luck Ghica!
Thank you so much for all you have done to let my app succeed.

--
You may want to add a leading zero sometimes, to make sure you always see 2 digits for the hours, mins, secs, like 01:08:05 etc.  You should be able to find a procedure for it in the forum, otherwise I will add it tonight.

--
Next time I do not reply when you write to me privately.
You wrote:

I want to add the fixed total amount hours, mins, secs like 01:08:05 at the end of slider.

I added it to the .aia attached. I think you could have done it yourself easily.
I also added a procedure to make sure you always have two digits for values, adding a leading zero if needed.

--
I am so sorry to send you in private.
Sure, I didn't tend to send it in private. In fact, by mistake I have opened my email instead of opening forum page:)
I am so happy to help me.
I have tested it and it is ok now.

--

댓글 없음:

댓글 쓰기