hansoninc / jquery.workout-timer

MIT License
0 stars 1 forks source link

Method to play & pause or restart? #1

Open anupalhub opened 6 years ago

anupalhub commented 6 years ago

Thanks for this nice script. Just want to know how could we achieve the timer to play or pause or restart from any method if available?

Thanks in advance

daverodriguez commented 6 years ago

Hi, Anupal. Thanks for your interest! Unfortunately, there are no public methods to play, pause, or restart the timer programmatically. It just wasn't something we needed when the plugin was created.

If you would like to add these methods and submit a pull request, we would gratefully accept it. Otherwise, you could try simulating click events to the play/pause and restart buttons using $.trigger(), like so:

// Play/pause
$('.workout-timer__play-pause').trigger('click');

// Reset
$('.workout-timer__reset').trigger('click');

There is a data-paused attribute on the .workout-timer_play-paused element that will tell you whether the control is currently playing or paused. Hope this helps!

anupalhub commented 6 years ago

Thanks for the tips. This is exactly what am trying now. But have some different use case. I actually require a separate rest timer to run on each round complete. Am not able to log the state of the counter which is changing to alternate while on duration2 loop.

The actual requirement is to pause the first timer on round complete of 45 secs and then run another for 15 secs, After that first timer will start it next round.

If i could get the state of counter of first timer then this would solve my problem. Moreover, in duration2 timing the onRoundComplete function also run, which i causing issue in my case.

Any idea how could I stop the duration2 timer to run onRoundComplete function.

Thanks

anupalhub commented 6 years ago

I tricked the code to do what i wanted to. So am wandering if the sound plays in iOS devices as well? Because its not seems to work on iOS devices? Can you please guide me through?

Thanks in advance.