-
Notifications
You must be signed in to change notification settings - Fork 55
Add call to stop audio playback #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this improvement @joebaird
The CI check failed due to code needing formatted. We have a guide that covers the process of using pre-commit
for that (and the pylint checks which CI will also enforce). https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code
Please run pre-commit run --all-files
and then make a new commit with the formatting changes that it makes.
thanks for the pointer! Ran pre-commit and fixed the whitespace issue. |
Good call, doesn't look like calling audio.stop() would cause any problems if nothing is playing, so adding it to the stop_play is a good addition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. Did not test. I'll try it out this week and get it merged. If another reviewer comes by to review / test in the meantime they can merge if successful and no other feedback.
Thanks again for working on this @joebaird! Congrats if this is your first open source contribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good to me, but I do not have a PyPortal to test on, but don't see why this would cause any issues.
# Conflicts: # adafruit_pyportal/peripherals.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged from main and resolved conflicts. In this case it ends up reverting the recently made change to use the with
context for play_file()
The usage of context processor was leading to issue: #118.
This PR resolves #118 by going back to not using the with
context processor. But we do have to add the exception for pylint to do this.
This PR also contains the change to add stop_play()
function.
I tested the stop_play()
functionality successfully and confirmed that this resolves #118 on:
Adafruit CircuitPython 7.1.0-beta.1 on 2021-11-30; Adafruit PyPortal with samd51j20
Board ID:pyportal
Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.9.6 from 3.9.5: > Merge pull request adafruit/Adafruit_CircuitPython_GPS#76 from mrdalgaard/main > update rtd py version Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 6.1.0 from 6.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#116 from joebaird/main > update rtd py version Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.10.4 from 1.10.3: > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#90 from todbot/main > update rtd py version Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.4.1 from 2.4.0: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#45 from dhalbert/make-package Updating https://github.com/adafruit/Adafruit_CircuitPython_RTTTL to 2.4.10 from 2.4.9: > Merge pull request adafruit/Adafruit_CircuitPython_RTTTL#29 from FoamyGuy/pyportal_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_TinyLoRa to 2.2.5 from 2.2.4: > update rtd py version
The play_file function added the ability to be non-blocking, but there is no call to stop audio playback and turn the speaker back off. This change adds a stop_play function that closes the wavfile and turns the speaker back off. This change required the wavfile variable to a class variable to allow access in the stop_play function.