10-20-2019, 03:01 PM
Ok, based on your reqts I think a simple Python script that implements a polling loop to check whether audio is playing and runs in the background would do the trick. It could also handle the 20 sec timer. You would launch it from /etc/rc.local
How long after play/pause/stop do you need to Amp to be turned on/off? This determined the polling interval.
To check whether audio is playing run the cmd below. It's checking ALSA output and is independent of which application is playing.
This example assumes card0 (I2S or On-board audio device). Use card1 for USB audio device.
-Tim
How long after play/pause/stop do you need to Amp to be turned on/off? This determined the polling interval.
To check whether audio is playing run the cmd below. It's checking ALSA output and is independent of which application is playing.
This example assumes card0 (I2S or On-board audio device). Use card1 for USB audio device.
Code:
# Audio playing
pi@rp3:~ $ cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 4410
buffer_size: 22050
# Audio not playing
pi@rp3:~ $ cat /proc/asound/card0/pcm0p/sub0/hw_params
closed
-Tim