you can use parts of the code in the GPIO volume control topic, but you would need an to use an other command to select the playlist instead of increase / decrease volume. “mpc add” should do the trick
Thanks for the hint. In the end, understanding the “mpc”, all became clear. Here is the code, which works excellent. An Arduino sends via RX/TX the command. I used a straight forward 1 and 2 over the serial line to select the playlist.
regards,
Olaf
#!/usr/bin/env python
import subprocess
import time
import serial
ser = serial.Serial('/dev/ttyAMA0', 9600)
while True:
select = ser.readline()
print ("you selected playlist" + select)
if select[0] == '1':
subprocess.call(['mpc', 'clear'])
subprocess.call(['mpc', 'load', 'PlayList_button_1'])
subprocess.call(['mpc', 'play'])
time.sleep(.2)
elif select[0] == '2':
subprocess.call(['mpc', 'clear'])
subprocess.call(['mpc', 'load', 'PlayList_button_2'])
subprocess.call(['mpc', 'play'])
time.sleep(.2)