Description
In the currently released version of this library calling pyportal.peripherals.play_file("somefile.wav", wait_to_finish=False)
results in no audio playing.
Full reproducer script:
import board
from adafruit_pyportal import PyPortal
# Create the PyPortal object
pyportal = PyPortal()
# Set display to show REPL
board.DISPLAY.show(None)
pyportal.peripherals.play_file("piano2.wav", wait_to_finish=False)
while True:
pass
Running the same code on version 6.0.0
of this library does play the wav file.
I think the change to use with
context processor is what is causing it not to play the file when wait_to_finish
is False
In this section of code it returns in the case of False
for wait_to_finish
the return causes it to close the with
context which closes the file and causes it not to be able to be played.
Adafruit_CircuitPython_PyPortal/adafruit_pyportal/peripherals.py
Lines 149 to 157 in a160fd1
Unless there is some way to make the lifetime of the with
block continue to remain open after the play_file()
function returns I think we would need to remove the usage of the with
. We could store the reference to the open file on self
and close it on subsequent calls before opening a new one.