Add pause/resume control to AudioOut and I2SOut#820
Conversation
dhalbert
left a comment
There was a problem hiding this comment.
Tested on CPX with a 13-second wav file. Works great!
There is inconsistency about whether you can call pause() twice in a row vs resume() twice in a row:
>>> a.pause()
>>> a.pause()
>>> a.resume()
>>> a.resume()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: No paused sample
Either both should give an error or it should be ok to call resume() while already playing. Having both be idempotent seems more generous to me: one less state check the user program has to make.
| raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self)); | ||
|
|
||
| if (!common_hal_audiobusio_i2sout_get_playing(self)) { | ||
| mp_raise_RuntimeError("No sample playing cannot pause"); |
There was a problem hiding this comment.
I was going to suggest adding a ":" to make "No sample playing: cannot pause", but how about just "Not playing"?
| raise_error_if_deinited(common_hal_audioio_audioout_deinited(self)); | ||
|
|
||
| if (!common_hal_audioio_audioout_get_playing(self)) { | ||
| mp_raise_RuntimeError("No sample playing cannot pause"); |
There was a problem hiding this comment.
I was going to suggest adding a ":" to make "No sample playing: cannot pause", but how about just "Not playing"?
|
Also if a sample has never started playing, could |
|
Or even better, only have |
|
If you just have |
|
maybe play-stop does a rewind. play-pause-play is like resume. This is the way music player buttons work, right? |
|
The new API also has the sample itself provided to |
|
do you want to regularize pause-pause vs resume-resume? |
|
Yup! Just saw that. Added in the latest commit. |
Fixes #808