Hi,
I have a raspberry pi 5 and I would like this:
1- Open a Full Screen web page with Chrome.
once the page is opened on my site the audio will start automatically. I managed this part with tutorials on the internet. It’s functional
But,
2- In Chrome, I want to check that the audio is playing and if it has stopped, send an email and restart the pi5.
Glad to hear you’ve got step one working already! How exactly did you do this? It may narrow or broaden our options depending on the libraries and methods used, so more information on this would be super helpful.
My initial thoughts are that you may be able to use a watchdog application paired with some sort of resource monitor, that depends on exact configuration though.
Thank you very much.
I have finaly make this on pyton but I am not able to place this script always on. i have test and I receved E-mail, that’s very cool but no work. Can you help me please?
import os
import smtplib
from email.mime.text import MIMEText
import time
# Configuration
EMAIL_FROM = 'log@imagein.ca'
EMAIL_TO = 'danielduplain@me.com'
EMAIL_SUBJECT = 'Audio Marcel Pelchat dans Chrome est arrêté'
SMTP_SERVER = 'box22.domaineinternet.ca'
SMTP_PORT = 587
SMTP_USER = 'lALLO@imagein.ca'
SMTP_PASSWORD = '000000'
def send_email():
msg = MIMEText("L'audio dans Chrome s'est arrêté.")
msg['Subject'] = EMAIL_SUBJECT
msg['From'] = EMAIL_FROM
msg['To'] = EMAIL_TO
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
server.starttls()
server.login(SMTP_USER, SMTP_PASSWORD)
server.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
def check_audio():
while True:
# Vérifie si l'audio est actif
audio_active = os.system("pactl list sink-inputs | grep -q 'RUNNING'") == 0
if not audio_active:
send_email()
break
time.sleep(10) # Vérifie toutes les 10 secondes
if __name__ == "__main__":
check_audio()
There are a couple ways you can set your script to be always on. The easiest is to have a script that won’t end and to run it when you boot your Pi. In your script set a loop that will check for audio and if it can’t detect it send an email, some delay for it to send, and then reboot your Pi.