Skip to content

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

Merged
merged 6 commits into from
Dec 13, 2021
Merged

Add call to stop audio playback #116

merged 6 commits into from
Dec 13, 2021

Conversation

joebaird
Copy link
Contributor

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.

Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

@joebaird
Copy link
Contributor Author

thanks for the pointer! Ran pre-commit and fixed the whitespace issue.

@joebaird joebaird requested a review from FoamyGuy October 19, 2021 17:12
@joebaird
Copy link
Contributor Author

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.

FoamyGuy
FoamyGuy previously approved these changes Oct 19, 2021
Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

Copy link
Member

@gamblor21 gamblor21 left a 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
@FoamyGuy FoamyGuy dismissed their stale review December 12, 2021 20:37

merged main + pylint exception

Copy link
Contributor

@FoamyGuy FoamyGuy left a 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

@FoamyGuy FoamyGuy merged commit 8031c95 into adafruit:main Dec 13, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 14, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants