Query if music is playing in balena-sound

Hello,

Because my USB speakers turn off automatically, I created a cron job in “bluetooth-audio” container that plays a 22Khz wav file with aplayer every 10 minutes. But If i’m listening to music this interferes. So I would like to create a scripts that queries if sound is playing in Balena-sound and if so the cron job exits. But I do not how to query if sound is playing. Should I query something from alsa? Or should I grep on the snapcast-client log? And if I have to query snapcast client log how do I connect to the snapcast-client container from " bluetooth-audio" container?

Thanks in advance!

Ronald

Hey, could you better describe the problem you’re having. If the speaker turns off due to inactivity and your solution was to play an audio clip via a cron job then wouldn’t playing music achieve the same result?

Unless you want to keep the speaker awake so when you play music there is no delay or boot up ?

Hello, thank you for your reply.
Due to inactivity the speaker turns off, usb device disappears, and alsa is missing default device.
To make alsa work again I have to:

  1. Turn on the speaker
  2. Restart balenasound

But I already figured out a workaround with a cron job an the following script:

if [ $running -gt 0 ]; then
echo its running >> /var/log/cron.log
else
echo its not running lets play wav file >> /var/log/cron.log
/usr/bin/aplay /root/silent.wav
fi

So this topic can be closed!
Thank you for replying!

Ronald

Hi @rbuffing – glad you found a workaround for your problem. I would definitely encourage you to file a feature request for balenaSound – this definitely sounds like something that could be improved. Would you be able to add logs from your device to that request, to show what’s being logged when this happens?

All the best,

Hugh

Hello, I will file the request. And add logs. Syslog will show USB device is disconnected after 10 minutes of not playing sound.