listen to sensor change for audio

main
vitrinekast 6 months ago
parent e1385a510a
commit bcc6e4147d

@ -98,11 +98,15 @@ def play_audio(file):
sound = sa.WaveObject.from_wave_file(file)
play_obj = sound.play()
# TODO: check for sensor data change
while play_obj.is_playing():
# Add a small delay to prevent high CPU usage
time.sleep(0.1)
load_media()
for i in range(12):
if mpr121[i].value:
print("Pin {} touched!".format(i))
load_media(i)
load_media(0)
def get_random_file(f):
print("getting random file from ")
@ -181,7 +185,7 @@ def load_media(region=None, override=None):
cv2.destroyAllWindows()
break
else:
print("ois the video finished?")
print("is the video finished?")
load_media(0)
break
elif file.endswith(".wav") or file.endswith(".mp3"):

Loading…
Cancel
Save