community icon indicating copy to clipboard operation
community copied to clipboard

[Audio]: Add 'on_eos' event

Open mak8kammerer opened this issue 2 years ago • 12 comments

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: xxx label.
  • [ ] Applied the api-deprecation or api-break label.
  • [ ] Applied the release-highlight label 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, versionchanged as needed.

mak8kammerer avatar Feb 11 '24 20:02 mak8kammerer

As well as unittests, this needs some documentation. I've read the code, and I am still just guessing what EOS stands for.

Julian-O avatar Feb 12 '24 02:02 Julian-O

Tests are ready. If somebody has any suggestions, let me know. Tests are not my thing.

mak8kammerer avatar Apr 02 '24 11:04 mak8kammerer

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.

gottadiveintopython avatar Apr 15 '24 13:04 gottadiveintopython

can use the kivy_clock pytest fixture instead of kivy.clock.Clock

Done. Thank you! Ready to review.

mak8kammerer avatar Apr 16 '24 10:04 mak8kammerer

Nice! You don't need the set_clock.

def test_on_eos_event(self, kivy_clock):
    ...

gottadiveintopython avatar Apr 16 '24 11:04 gottadiveintopython

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.

mak8kammerer avatar Apr 16 '24 11:04 mak8kammerer

It won't work.

Sorry, I didn't know that.

gottadiveintopython avatar Apr 17 '24 20:04 gottadiveintopython

@misl6, could you please review my PR, as it seems that @Julian-O is offline for long time.

Sorry for pinging.

mak8kammerer avatar Apr 29 '24 18:04 mak8kammerer

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

gottadiveintopython avatar May 03 '24 11:05 gottadiveintopython

Seems like on_play and on_stop events work differently depending on audio providers when sound.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.

mak8kammerer avatar May 03 '24 14:05 mak8kammerer

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.

gottadiveintopython avatar May 03 '24 21:05 gottadiveintopython