[Audio]: Add 'on_eos' event
Good evening!
I want to add on_eos event to Kivy audio system. It works the same way as in the video, but is only available with ffpyplayer and gstplayer providers.
Related issue: #2156.
~P.S.: Could someone please advise me on how the tests for this PR should look? Or is it not necessary to write them for this case?~
Maintainer merge checklist
- [ ] Title is descriptive/clear for inclusion in release notes.
- [x] Applied a
Component: xxxlabel. - [ ] Applied the
api-deprecationorapi-breaklabel. - [ ] Applied the
release-highlightlabel to be highlighted in release notes. - [ ] Added to the milestone version it was merged into.
- [x] Unittests are included in PR.
- [x] Properly documented, including
versionadded,versionchangedas needed.
As well as unittests, this needs some documentation. I've read the code, and I am still just guessing what EOS stands for.
Tests are ready. If somebody has any suggestions, let me know. Tests are not my thing.
I'm not familiar with the audio providers so I have nothing to say about it, but you can use the kivy_clock pytest fixture instead of kivy.clock.Clock, which makes the unittests have less side-effects.
can use the
kivy_clockpytest fixture instead ofkivy.clock.Clock
Done. Thank you! Ready to review.
Nice! You don't need the set_clock.
def test_on_eos_event(self, kivy_clock):
...
Nice! You don't need the
set_clock.def test_on_eos_event(self, kivy_clock): ...
It won't work. Take a look at this StackOverflow question and this code snippet.
It won't work.
Sorry, I didn't know that.
@misl6, could you please review my PR, as it seems that @Julian-O is offline for long time.
Sorry for pinging.
Seems like on_play and on_stop events work differently depending on audio providers when sound.loop = True.
- sdl2 ... these events will be fired in each iteration
- gstplayer ... nothing will be fired in each iteration
Seems like
on_playandon_stopevents work differently depending on audio providers whensound.loop = True.* sdl2 ... these events will be fired every iteration * gstplayer ... nothing will be fired during the loop
This is not related with this PR. I think it should be clarified in a separate issue.
Yes, I'll open an issue. (Sorry I forgot to mention that the issue occurs on the master branch)
The reason I mentioned the issue is that, unless we define when on_play and on_stop events should occur, it's probably hard to document about the difference between on_eos and on_stop.