Add playback controls to Timer#249
Merged
Merged
Conversation
This comes with a few breaking changes to code but not to behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Changes the
Timerclass to enable playback control, cycle detection, and progress tracking.It replaces the previous static methods with instance methods. The changes also update dependent systems to use the new API.It also changes the constructor ofTimerto pass a configuration object.Solution
The new implementation provides:
play(),pause(),start(),stop(),seek()andreset()cycleStarted()andcycleEnded()methods which detect when timer cycles begin and end respectively.progress()method which returns normalized progress (0.0 to 1.0) andelapsedwhich returns the time in seconds the timer has moved forward.playbackChanged()method detects when playback state is modified andrequestPlaybackwhich marks a playback is required by the timer.Showcase
Basic Timer Usage:
Migration Guide
new Timer(duration, mode)withnew Timer({duration, mode})timer.finishedchecks withtimer.cycleStarted()ortimer.cycleEnded()if checking for cycle orcompletedto check if timer has completedChecklist