NoteBlockAPI icon indicating copy to clipboard operation
NoteBlockAPI copied to clipboard

Events called by SongPlayer's loop can't be cancelled

Open koca2000 opened this issue 4 years ago • 1 comments

When an event is called from SongPlayer's loop which is in async thread it can't be cancelled. Affected events are: SongLoopEvent and SongDestroyingEvent.

SongPlayer also continues playing the Song without waiting for event listeners of events bellow to finish their execution. Affected events are: SongStoppedEvent, SongNextEvent and SongEndEvent. For example when SongPlayer is paused in SongNextEvent it plays first few notes of the next Song before it's paused.

It is caused by schedulling the events execution in order to execute them in synchronized thread (not async with server main thread).

koca2000 avatar Aug 22 '20 23:08 koca2000

Simply calling event off-thread solves this

ishland avatar Aug 23 '20 01:08 ishland