Skip to content

Commit

Permalink
Merge pull request #117 from adafruit/patch-fix
Browse files Browse the repository at this point in the history
Linted
  • Loading branch information
kattni authored Nov 5, 2021
2 parents 13ac90b + f66b129 commit 3e95266
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions adafruit_pyportal/peripherals.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,14 @@ def play_file(self, file_name, wait_to_finish=True):
:param str file_name: The name of the wav file to play on the speaker.
"""
wavfile = open(file_name, "rb")
wavedata = audiocore.WaveFile(wavfile)
self._speaker_enable.value = True
self.audio.play(wavedata)
if not wait_to_finish:
return
while self.audio.playing:
pass
wavfile.close()
with open(file_name, "rb") as wavfile:
wavedata = audiocore.WaveFile(wavfile)
self._speaker_enable.value = True
self.audio.play(wavedata)
if not wait_to_finish:
return
while self.audio.playing:
pass
self._speaker_enable.value = False

def sd_check(self):
Expand Down

0 comments on commit 3e95266

Please sign in to comment.