adafruit / Adafruit_CircuitPython_PyPortal

CircuitPython driver for Adafruit PyPortal.
MIT License
45 stars 56 forks source link

Add call to stop audio playback #116

Closed joebaird closed 2 years ago

joebaird commented 2 years ago

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.

joebaird commented 2 years ago

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

joebaird commented 2 years ago

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.