listen to sensor change for audio

main
vitrinekast 5 months ago
parent e1385a510a
commit bcc6e4147d

@ -98,11 +98,15 @@ def play_audio(file):
sound = sa.WaveObject.from_wave_file(file) sound = sa.WaveObject.from_wave_file(file)
play_obj = sound.play() play_obj = sound.play()
# TODO: check for sensor data change
while play_obj.is_playing(): while play_obj.is_playing():
# Add a small delay to prevent high CPU usage # Add a small delay to prevent high CPU usage
time.sleep(0.1) 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): def get_random_file(f):
print("getting random file from ") print("getting random file from ")
@ -181,7 +185,7 @@ def load_media(region=None, override=None):
cv2.destroyAllWindows() cv2.destroyAllWindows()
break break
else: else:
print("ois the video finished?") print("is the video finished?")
load_media(0) load_media(0)
break break
elif file.endswith(".wav") or file.endswith(".mp3"): elif file.endswith(".wav") or file.endswith(".mp3"):

Loading…
Cancel
Save