jeroenwalter/managed-midi

Stop and Seek should be immediate actions.

jeroenwalter opened this issue · 2 comments

WaitBy blocks the calling thread for a specified duration in milliseconds.
This has the unfortunate consequence that if a midi event for instance has a delta time of 5 seconds, that the play thread is blocked for 5 seconds.
A Stop or Seek command will then be effectuated after those 5 seconds.
This can be solved by making IMidiPlayerTimeManager.WaitBy abortable or by having a different way of waiting the appropriate amount of time dictated by the delta time.

Also this behaviour prevents regular playback progress updates, as during the wait no progress can be reported back.

Furthermore, seeking should not trigger the public EventReceived of MidiPlayer.
The goal is to seek to a position, not to replay the entire midi file upto the position.
Subscribers of MidiPlayer.EventReceived should not be triggered by this.
This may be implemented by giving the MidiEventLooper.EventReceived event an argument that tells the MidiPlayer that the event is a normal play event or if it is the result of the seeking process.